diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-04-16 17:20:53 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-04-17 16:18:01 +0200 |
| commit | 111c15c48e618b30a0cf11d91b135d87d73053a4 (patch) | |
| tree | f5fbf6d649306315c457e2844b605da469031873 /src/ci | |
| parent | d14df2652df492fe0f19c5e0ae5041b39b5a4d20 (diff) | |
| download | rust-111c15c48e618b30a0cf11d91b135d87d73053a4.tar.gz rust-111c15c48e618b30a0cf11d91b135d87d73053a4.zip | |
Extract function for normalizing path delimiters to `utils`
Diffstat (limited to 'src/ci')
| -rw-r--r-- | src/ci/citool/src/analysis.rs | 13 | ||||
| -rw-r--r-- | src/ci/citool/src/utils.rs | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/ci/citool/src/analysis.rs b/src/ci/citool/src/analysis.rs index 9fc7c309bfb..62974be2dbe 100644 --- a/src/ci/citool/src/analysis.rs +++ b/src/ci/citool/src/analysis.rs @@ -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, diff --git a/src/ci/citool/src/utils.rs b/src/ci/citool/src/utils.rs index a4c6ff85ef7..0367d349a1e 100644 --- a/src/ci/citool/src/utils.rs +++ b/src/ci/citool/src/utils.rs @@ -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() } +} |
