rtk-ai/rtk · error
invalid ctest result terminator regex
Error message
invalid ctest result terminator regex
What it means
Panic from the .expect() guarding RESULT_TERMINATOR_RE in src/cmds/system/ctest_cmd.rs, the regex matching the trailing '<duration> sec' that marks the end of a ctest result line. Like all rtk filter regexes it compiles lazily on first use; an invalid pattern panics with this message rather than returning Result. It is an internal invariant: the shipped pattern `r"[\d.]+\s+sec\s*$"` is valid, so the panic only fires on corrupted/edited source builds.
Solutions
- Inspect the RESULT_TERMINATOR_RE literal in src/cmds/system/ctest_cmd.rs and fix any regex syntax error
- Add/run a unit test that touches the static (`cargo test ctest`) to confirm compilation
- Use `rtk proxy ctest ...` as a workaround to get raw ctest output without the filter
- Rebuild the binary after fixing: `cargo build`
Example fix
// before
Regex::new(r"[\d.]+\s+sec\s*$").expect("invalid ctest result terminator regex")
// after (corrected class if it was broken, e.g. missing bracket)
Regex::new(r"[\d.]+\s+sec\s*$").expect("invalid ctest result terminator regex") Defensive patterns
Strategy: validation
Validate before calling
assert!(regex::Regex::new(r"[\d.]+\s+sec\s*$").is_ok(), "RESULT_TERMINATOR_RE must compile");
Prevention
- Unit-test each LazyLock regex static at least once
- Never hand-edit character classes without running cargo test
- Pin the regex crate version to avoid syntax drift
- Use `rtk proxy ctest ...` to bypass the filter
When it happens
Trigger: First access of RESULT_TERMINATOR_RE while filtering ctest output, if a source modification introduced invalid regex syntax (unbalanced character class, invalid escape).
Common situations: Hand-edited regex typo in the ctest filter; merge conflict resolved with a partially deleted pattern; regex crate version change altering accepted syntax.
Related errors
- invalid ctest result prefix regex
- invalid ctest start regex
- invalid ctest summary regex
- invalid ctest time regex
- invalid ctest result regex
AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19).
Data as JSON: /api/errors/ae835d8a420a00e9.
Report an issue: GitHub.
Appendix: source
Thrown at src/cmds/system/ctest_cmd.rs:34
const MAX_FAILURE_HEAD_LINES: usize = 2;
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 0924356b4c)