Skip to content

Commit 111c15c

Browse files
committed
Extract function for normalizing path delimiters to utils
1 parent d14df26 commit 111c15c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/ci/citool/src/analysis.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use build_helper::metrics::{
88
};
99

1010
use crate::github::JobInfoResolver;
11-
use crate::metrics;
1211
use crate::metrics::{JobMetrics, JobName, get_test_suites};
1312
use crate::utils::{output_details, pluralize};
13+
use crate::{metrics, utils};
1414

1515
/// Outputs durations of individual bootstrap steps from the gathered bootstrap invocations,
1616
/// and also a table with summarized information about executed tests.
@@ -394,18 +394,17 @@ fn aggregate_tests(metrics: &JsonRoot) -> TestSuiteData {
394394
// Poor man's detection of doctests based on the "(line XYZ)" suffix
395395
let is_doctest = matches!(suite.metadata, TestSuiteMetadata::CargoPackage { .. })
396396
&& test.name.contains("(line");
397-
let test_entry = Test { name: generate_test_name(&test.name), stage, is_doctest };
397+
let test_entry = Test {
398+
name: utils::normalize_path_delimiters(&test.name).to_string(),
399+
stage,
400+
is_doctest,
401+
};
398402
tests.insert(test_entry, test.outcome.clone());
399403
}
400404
}
401405
TestSuiteData { tests }
402406
}
403407

404-
/// Normalizes Windows-style path delimiters to Unix-style paths.
405-
fn generate_test_name(name: &str) -> String {
406-
name.replace('\\', "/")
407-
}
408-
409408
/// Prints test changes in Markdown format to stdout.
410409
fn report_test_diffs(
411410
diff: AggregatedTestDiffs,

src/ci/citool/src/utils.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::path::Path;
23

34
use anyhow::Context;
@@ -28,3 +29,8 @@ where
2829
func();
2930
println!("</details>\n");
3031
}
32+
33+
/// Normalizes Windows-style path delimiters to Unix-style paths.
34+
pub fn normalize_path_delimiters(name: &str) -> Cow<str> {
35+
if name.contains("\\") { name.replace('\\', "/").into() } else { name.into() }
36+
}

0 commit comments

Comments
 (0)