Skip to content

Commit 5d3b386

Browse files
committed
Canonicalize paths for CI
1 parent 69597b3 commit 5d3b386

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ impl Default for Config {
7474
}
7575
}
7676

77+
impl Config {
78+
pub fn stderr_filter(&mut self, pattern: &str, replacement: &'static str) {
79+
self.stderr_filters
80+
.push((Regex::new(pattern).unwrap(), replacement));
81+
}
82+
}
83+
7784
#[derive(Debug)]
7885
pub struct DependencyBuilder {
7986
pub program: PathBuf,

tests/integrations/basic/tests/actual_tests/foomp.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ error[E0308]: mismatched types
77
| arguments to this function are incorrect
88
|
99
note: function defined here
10-
--> /home/ubuntu/crates/ui_test/tests/integrations/basic/src/lib.rs:1:8
10+
--> $DIR/tests/integrations/basic/src/lib.rs:1:8
1111
|
1212
1 | pub fn add(left: usize, right: usize) -> usize {
1313
| ^^^
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
use ui_test::*;
22

33
fn main() -> ui_test::color_eyre::Result<()> {
4-
let config = Config {
4+
let path = "../../../target";
5+
let mut config = Config {
56
quiet: false,
67
root_dir: "tests/actual_tests".into(),
78
dependencies_crate_manifest_path: Some("tests/dummy_crate/Cargo.toml".into()),
89
dependency_builder: Some(DependencyBuilder {
910
program: std::path::PathBuf::from("cargo"),
1011
args: vec![],
11-
envs: vec![("CARGO_TARGET_DIR".into(), "../../../target".into())],
12+
envs: vec![("CARGO_TARGET_DIR".into(), path.into())],
1213
}),
1314
args: vec!["--edition=2021".into()],
1415
output_conflict_handling: if std::env::var_os("BLESS").is_some() {
1516
OutputConflictHandling::Bless
1617
} else {
1718
OutputConflictHandling::Error
1819
},
19-
.. Config::default()
20+
..Config::default()
2021
};
22+
config.stderr_filter(r"[^ ]*/\.?cargo/registry/.*/", "$$CARGO_REGISTRY");
23+
config.stderr_filter(
24+
&std::path::Path::new(path)
25+
.canonicalize()
26+
.unwrap()
27+
.parent()
28+
.unwrap()
29+
.display()
30+
.to_string(),
31+
"$$DIR",
32+
);
2133
ui_test::run_tests(config)
2234
}

0 commit comments

Comments
 (0)