Extract function for normalizing path delimiters to utils

This commit is contained in:
Jakub Beránek 2025-04-16 17:20:53 +02:00
parent d14df2652d
commit 111c15c48e
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 12 additions and 7 deletions

View file

@ -8,9 +8,9 @@ use build_helper::metrics::{
};
use crate::github::JobInfoResolver;
use crate::metrics;
use crate::metrics::{JobMetrics, JobName, get_test_suites};
use crate::utils::{output_details, pluralize};
use crate::{metrics, utils};
/// Outputs durations of individual bootstrap steps from the gathered bootstrap invocations,
/// and also a table with summarized information about executed tests.
@ -394,18 +394,17 @@ fn aggregate_tests(metrics: &JsonRoot) -> TestSuiteData {
// Poor man's detection of doctests based on the "(line XYZ)" suffix
let is_doctest = matches!(suite.metadata, TestSuiteMetadata::CargoPackage { .. })
&& test.name.contains("(line");
let test_entry = Test { name: generate_test_name(&test.name), stage, is_doctest };
let test_entry = Test {
name: utils::normalize_path_delimiters(&test.name).to_string(),
stage,
is_doctest,
};
tests.insert(test_entry, test.outcome.clone());
}
}
TestSuiteData { tests }
}
/// Normalizes Windows-style path delimiters to Unix-style paths.
fn generate_test_name(name: &str) -> String {
name.replace('\\', "/")
}
/// Prints test changes in Markdown format to stdout.
fn report_test_diffs(
diff: AggregatedTestDiffs,

View file

@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::path::Path;
use anyhow::Context;
@ -28,3 +29,8 @@ where
func();
println!("</details>\n");
}
/// Normalizes Windows-style path delimiters to Unix-style paths.
pub fn normalize_path_delimiters(name: &str) -> Cow<str> {
if name.contains("\\") { name.replace('\\', "/").into() } else { name.into() }
}