{"record":{"id":"b4eee058f3c330fd","repo":"rtk-ai/rtk","slug":"invalid-ctest-time-regex","errorCode":null,"errorMessage":"invalid ctest time regex","messagePattern":"invalid ctest time regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":45,"sourceCode":"    )\n    .expect(\"invalid ctest result regex\")\n});\nstatic RESULT_PREFIX_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*(?:\\d+/\\d+\\s+)?Test\\s+#\\d+:\").expect(\"invalid ctest result prefix regex\")\n});\nstatic RESULT_TERMINATOR_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"[\\d.]+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")\n});\nstatic START_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$\").expect(\"invalid ctest start regex\")\n});\nstatic SUMMARY_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\")\n        .expect(\"invalid ctest summary regex\")\n});\nstatic TIME_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*Total Test time \\(real\\)\\s+=\\s+([\\d.]+)\\s+sec\")\n        .expect(\"invalid ctest time regex\")\n});\n\n#[derive(Debug, Clone)]\nstruct TestCase {\n    number: u32,\n    name: String,\n    status: String,\n    reason: Option<String>,\n    duration: f64,\n    line_index: usize,\n    counter_total: Option<u32>,\n}\n\n#[derive(Debug)]\nstruct ParsedTests {\n    tests: Vec<TestCase>,\n    result_lines: Vec<usize>,\n    run_total: Option<u32>,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/system/ctest_cmd.rs#L27-L63","documentation":"Panic from the .expect() on TIME_RE in src/cmds/system/ctest_cmd.rs, which reads the total duration from ctest's 'Total Test time (real) = N sec' line. The regex compiles lazily inside a LazyLock; invalid pattern syntax aborts with this message instead of returning an error. This is an internal invariant guard; the shipped pattern is valid, so it fires only when the source was modified incorrectly.","triggerScenarios":"First access of TIME_RE during `rtk ctest` output filtering, when a source edit made the regex syntactically invalid (e.g. unescaped parenthesis removed from \\(real\\)).","commonSituations":"Hand-edit typo in the time regex; broken merge; building with a regex crate whose syntax rules reject the pattern.","solutions":["Fix the TIME_RE literal in src/cmds/system/ctest_cmd.rs (keep `(real)` escaped as \\(real\\))","Run `cargo test ctest` to confirm the static compiles","Work around with `rtk proxy ctest ...` for raw output","Rebuild the binary after fixing"],"exampleFix":"// before (broken: real parens unescaped)\nRegex::new(r\"^\\s*Total Test time (real)\\s+=\\s+([\\d.]+)\\s+sec\").expect(\"invalid ctest time regex\")\n// after\nRegex::new(r\"^\\s*Total Test time \\(real\\)\\s+=\\s+([\\d.]+)\\s+sec\").expect(\"invalid ctest time regex\")","handlingStrategy":"validation","validationCode":"assert!(regex::Regex::new(r\"^\\s*Total Test time \\(real\\)\\s+=\\s+([\\d.]+)\\s+sec\").is_ok(), \"TIME_RE must compile\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember to escape literal parentheses like (real) inside regex","Keep a fixture-based test for the Total Test time line","Run the pre-commit gate (fmt/clippy/test) after regex edits","Use `rtk proxy ctest ...` to bypass filtering"],"tags":["rust","regex","panic","ctest"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}