rtk-ai/rtk · critical

invalid ctest result terminator regex

Error message

invalid ctest result terminator regex

What it means

This is a panic from `.expect("invalid ctest result terminator regex")` on `Regex::new` inside the RESULT_TERMINATOR_RE LazyLock static at src/cmds/system/ctest_cmd.rs:35. The pattern `r"[\d.]+\s+sec\s*$"` identifies lines ending a ctest result block; the panic means the regex failed to parse. Because it is a LazyLock, the crash happens at first use during ctest output filtering, not at binary startup.

Source

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

const MAX_FAILED_LIST_LINES: usize = CAP_LIST;
const MAX_DETECT_PREAMBLE_LINES: usize = 4;
// 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,

View on GitHub (pinned to 36788f6bd4)

Solutions

  1. Read the RESULT_TERMINATOR_RE literal at src/cmds/system/ctest_cmd.rs:35-36 and correct the regex syntax (check character class is closed with `]`)
  2. Compile-test the pattern in isolation (regex101 Rust flavor or a unit test) before rebuilding
  3. Restore the known-good pattern: r"[\d.]+\s+sec\s*$"
  4. Run `cargo test ctest` and `cargo clippy --all-targets` after the fix

Example fix

// before (unterminated character class)
Regex::new(r"[\d.+\s+sec\s*$").expect("invalid ctest result terminator regex")
// after
Regex::new(r"[\d.]+\s+sec\s*$").expect("invalid ctest result terminator regex")
Defensive patterns

Strategy: validation

Validate before calling

fn assert_terminator_regex_valid() {
    assert!(regex::Regex::new(r"[\d.]+\s+sec\s*$").is_ok());
}

Prevention

When it happens

Trigger: First invocation of the ctest filter after the RESULT_TERMINATOR_RE pattern literal was edited into an invalid form — e.g. an unclosed character class `[\d.` (unescaped `[`), a bad escape sequence, or a corrupted `$` anchor.

Common situations: Editing the character class to add separators (e.g. `[\d.,]`) and accidentally deleting the `]`, regex-escaping mistakes when switching from a raw string to a regular string (backslashes being eaten), or an incomplete merge of the static block.

Related errors


AI-assisted analysis of rtk-ai/rtk@36788f6bd4 (2026-09-03). Data as JSON: /api/errors/ae835d8a420a00e9. Report an issue: GitHub.