Skip to content

Commit

Permalink
Upgrade ui_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli committed Aug 24, 2023
1 parent cf7cea4 commit 2268041
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test-crates/duchess-java-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ duchess = { path = "../.." }
thiserror = "1.0.40"

[dev-dependencies]
ui_test = "0.10.0"
ui_test = "0.17.0"

[build_dependencies]
walkdir = "2.3"
Expand Down
31 changes: 23 additions & 8 deletions test-crates/duchess-java-tests/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,35 @@ fn main() -> color_eyre::eyre::Result<()> {
// Tests can be blessed with `cargo test -- -- --bless`.
let bless = std::env::args().any(|arg| arg == "--bless");

let mut config = Config::default();
config.root_dir = Path::new("tests").join("ui");
let root_dir = Path::new("tests").join("ui");
let mut config = Config {
..Config::cargo(root_dir.clone())
};
let args = Args::test()?;

if bless {
config.output_conflict_handling = OutputConflictHandling::Bless;
}

// Place the build artifacts in the `../target/ui` directory instead of in the
// crate root.
config.out_dir = Some(Path::new("..").join("target").join("ui"));
config.out_dir = Path::new("..").join("target").join("ui");

// Make sure we can depend on duchess itself in our tests
config.dependencies_crate_manifest_path = Some("Cargo.toml".into());
config.dependencies_crate_manifest_path = Some(Path::new("Cargo.toml").into());

let test_name = std::env::var_os("TESTNAME");

let text = if args.quiet {
ui_test::status_emitter::Text::quiet()
} else {
ui_test::status_emitter::Text::verbose()
};

run_tests_generic(
config,
move |path| {
vec![config],
args,
move |path, _, _| {
test_name
.as_ref()
.and_then(|name| {
Expand All @@ -38,7 +48,12 @@ fn main() -> color_eyre::eyre::Result<()> {
.unwrap_or(true)
&& path.extension().map(|ext| ext == "rs").unwrap_or(false)
},
|_, _| None,
status_emitter::TextAndGha,
default_per_file_config,
(
text,
ui_test::status_emitter::Gha::<true> {
name: "ui tests".into(),
},
)
)
}

0 comments on commit 2268041

Please sign in to comment.