Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/cases/markdownlint-cli2/failure/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ args = "run --full markdownlint-cli2"
exit = 1
stderr = '''
[markdownlint-cli2]
markdownlint-cli2 v0.17.2 (markdownlint v0.37.4)
markdownlint-cli2 <VERSION>
Finding: <REPO>/README.md
Linting: 1 file(s)
Summary: 1 error(s)
Expand Down
19 changes: 15 additions & 4 deletions tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ fn run_case(case: &Path, name: &str, update: bool) {
let repo_canonical_str = canonical_repo_path(repo.path());
let normalize =
|s: String| -> String { normalize_output(s, repo_str.as_ref(), &repo_canonical_str) };
let stderr = normalize_timing(&strip_ansi(&normalize(
let stderr = normalize_tool_versions(&normalize_timing(&strip_ansi(&normalize(
String::from_utf8_lossy(&out.stderr).into_owned(),
)));
let stdout = normalize_timing(&strip_ansi(&normalize(
))));
let stdout = normalize_tool_versions(&normalize_timing(&strip_ansi(&normalize(
String::from_utf8_lossy(&out.stdout).into_owned(),
)));
))));

if update {
write_test_toml(
Expand Down Expand Up @@ -391,6 +391,17 @@ fn normalize_timing(s: &str) -> String {
.into_owned()
}

/// Replaces tool version banners with a stable `<VERSION>` placeholder so
/// snapshots don't need updating on every dependency bump.
fn normalize_tool_versions(s: &str) -> String {
use regex::Regex;
// markdownlint-cli2 vX.Y.Z (markdownlint vA.B.C)
let re =
Regex::new(r"markdownlint-cli2 v\d+\.\d+\.\d+ \(markdownlint v\d+\.\d+\.\d+\)").unwrap();
re.replace_all(s, "markdownlint-cli2 <VERSION>")
.into_owned()
}

/// Strips ANSI/VT escape sequences (colour codes, character-set switches, etc.).
/// TOML strings cannot contain raw control characters, so these must be removed.
fn strip_ansi(s: &str) -> String {
Expand Down
Loading