rtk-ai/rtk · error

invalid ctest result regex

Error message

invalid ctest result regex

What it means

A .expect() panic guard on the hardcoded ctest result-parsing regex at module load inside the ctest filter. The pattern is a static literal; this only fires if the regex source itself is invalid after an edit, never from runtime ctest output.

Source

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

use crate::core::runner::{self, RunOptions};
use crate::core::truncate::{self, CAP_LIST, CAP_WARNINGS};
use crate::core::utils::{resolved_command, strip_ansi};

const MAX_SLOWEST: usize = 3;
const MAX_FAILURE_LINES: usize = CAP_WARNINGS;
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")

View on GitHub (pinned to 36788f6bd4)

Solutions

  1. Fix the regex literal for the ctest result pattern in src/cmds/system/ctest_cmd.rs
  2. Check for unescaped parentheses, brackets, or repetition operators
  3. Run cargo test ctest to verify the pattern compiles and parses fixtures correctly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/cmds/system/ctest_cmd.rs:28 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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