rtk-ai/rtk · error

invalid ctest start regex

Error message

invalid ctest start regex

What it means

Panic message from the .expect() on START_RE in src/cmds/system/ctest_cmd.rs, which matches ctest 'Start N:' lines to capture the test executable being launched. rtk compiles this lazily at first filter use; invalid regex syntax aborts with this message instead of an error value. The shipped pattern is valid, so this is an internal invariant violation only reachable from broken source builds.

Solutions

  1. Fix the regex syntax in the START_RE literal in src/cmds/system/ctest_cmd.rs
  2. Run `cargo test ctest` (or any test touching the static) to validate compilation
  3. Bypass the filter with `rtk proxy ctest ...` if you need output immediately
  4. Rebuild with `cargo build` after the fix

Example fix

// before
Regex::new(r"^\s*Start\s+(\d+):\s*(.*?)\s*$").expect("invalid ctest start regex")
// after (balance groups if one was removed)
Regex::new(r"^\s*Start\s+(\d+):\s*(.*?)\s*$").expect("invalid ctest start regex")
Defensive patterns

Strategy: validation

Validate before calling

assert!(regex::Regex::new(r"^\s*Start\s+(\d+):\s*(.*?)\s*$").is_ok(), "START_RE must compile");

Prevention

When it happens

Trigger: First access of START_RE during an `rtk ctest` run after a source edit introduced invalid regex syntax in the pattern (bad group, invalid escape sequence).

Common situations: Developer typo while tuning the Start-line regex; broken merge of the statics block; older regex crate rejecting newer syntax.

Related errors


AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19). Data as JSON: /api/errors/f4e2ed222493cfb2. Report an issue: GitHub.

Appendix: source

Thrown at src/cmds/system/ctest_cmd.rs:37

// Failure entries carry a header plus up to `MAX_FAILURE_LINES` detail lines each,
// so this list deviates below `CAP_LIST`; the single-line skipped and raw-trailer
// lists keep the full cap.
const MAX_FAILED_BLOCK_ENTRIES: usize = truncate::reduced(CAP_LIST, 5);

static TEST_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(
        r"(?s)^\s*(?:\d+/(\d+)\s+)?Test\s+#(\d+):\s+(.+?)\s+\.{2,}\s*(?:\*{3})?\s*(.+?)\s+([\d.]+)\s+sec\s*$",
    )
    .expect("invalid ctest result regex")
});
static RESULT_PREFIX_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r"^\s*(?:\d+/\d+\s+)?Test\s+#\d+:").expect("invalid ctest result prefix regex")
});
static RESULT_TERMINATOR_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r"[\d.]+\s+sec\s*$").expect("invalid ctest result terminator regex")
});
static START_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r"^\s*Start\s+(\d+):\s*(.*?)\s*$").expect("invalid ctest start regex")
});
static SUMMARY_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r"^\s*\d+%\s+tests passed,\s+(\d+)\s+tests failed out of\s+(\d+)")
        .expect("invalid ctest summary regex")
});
static TIME_RE: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r"^\s*Total Test time \(real\)\s+=\s+([\d.]+)\s+sec")
        .expect("invalid ctest time regex")
});

#[derive(Debug, Clone)]
struct TestCase {
    number: u32,
    name: String,
    status: String,
    reason: Option<String>,
    duration: f64,
    line_index: usize,

View on GitHub (pinned to 0924356b4c)