rtk-ai/rtk · error

invalid ctest summary regex

Error message

invalid ctest summary regex

What it means

Panic from the .expect() guarding SUMMARY_RE in src/cmds/system/ctest_cmd.rs, which extracts pass/fail counts from ctest's 'N% tests passed, M tests failed out of T' summary line. The regex is compiled lazily in a LazyLock static; invalid syntax panics with this message at first filter use rather than surfacing an error. It is an internal invariant — the shipped pattern is valid and end users should never hit it.

Solutions

  1. Correct the regex syntax in the SUMMARY_RE literal in src/cmds/system/ctest_cmd.rs
  2. Validate with `cargo test ctest` or a one-off Regex::new test
  3. Use `rtk proxy ctest ...` to get unfiltered ctest output as a workaround
  4. Rebuild: `cargo build`

Example fix

// before
Regex::new(r"^\s*\d+%\s+tests passed,\s+(\d+)\s+tests failed out of\s+(\d+)").expect("invalid ctest summary regex")
// after (restore the missing closing group)
Regex::new(r"^\s*\d+%\s+tests passed,\s+(\d+)\s+tests failed out of\s+(\d+)").expect("invalid ctest summary regex")
Defensive patterns

Strategy: validation

Validate before calling

assert!(regex::Regex::new(r"^\s*\d+%\s+tests passed,\s+(\d+)\s+tests failed out of\s+(\d+)").is_ok(), "SUMMARY_RE must compile");

Prevention

When it happens

Trigger: First access of SUMMARY_RE while summarizing ctest output, if the pattern in the source was edited into an invalid form (unbalanced parenthesis, invalid escape).

Common situations: Regex typo during a filter change; partially applied patch/merge to the statics block; regex crate version incompatibility.

Related errors


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

Appendix: source

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

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,
    counter_total: Option<u32>,
}

#[derive(Debug)]

View on GitHub (pinned to 0924356b4c)