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
- Fix the regex syntax in the START_RE literal in src/cmds/system/ctest_cmd.rs
- Run `cargo test ctest` (or any test touching the static) to validate compilation
- Bypass the filter with `rtk proxy ctest ...` if you need output immediately
- 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
- Add a compile-check test for START_RE
- Resolve merge conflicts in the regex statics block carefully
- Test regex changes with real ctest fixtures
- Workaround via `rtk proxy ctest ...`
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
- invalid ctest result prefix regex
- invalid ctest result terminator 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/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)