Skip to content

Commit d80936b

Browse files
committed
chore: support argument parsing in cargo ui tests
Since `run_tests_generic()` doesn't parse arguments, I took the contents of `run_tests()` and inlined them here.
1 parent 331f2e3 commit d80936b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

bevy_lint/tests/ui_cargo.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
process::{Command, Stdio},
55
};
66

7-
use ui_test::{CommandBuilder, Config, OptWithLine, status_emitter};
7+
use ui_test::{Args, CommandBuilder, Config, Format, OptWithLine, status_emitter::{self, StatusEmitter}};
88

99
// This is set by Cargo to the absolute paths of `bevy_lint` and `bevy_lint_driver`.
1010
const LINTER_PATH: &str = env!("CARGO_BIN_EXE_bevy_lint");
@@ -52,6 +52,21 @@ fn main() {
5252
);
5353
});
5454

55+
let args = Args::test().unwrap();
56+
57+
if let Format::Pretty = args.format {
58+
println!(
59+
"Compiler: {}",
60+
config.program.display().to_string().replace('\\', "/")
61+
);
62+
}
63+
64+
let name = config.root_dir.display().to_string().replace('\\', "/");
65+
66+
let emitter: Box<dyn StatusEmitter> = args.format.into();
67+
68+
config.with_args(&args);
69+
5570
// Run this `Config` for all paths that end with `Cargo.toml` resulting
5671
// only in the `Cargo` lints.
5772
ui_test::run_tests_generic(
@@ -61,7 +76,7 @@ fn main() {
6176
.then(|| ui_test::default_any_file_filter(path, config))
6277
},
6378
|_config, _file_contents| {},
64-
status_emitter::Text::verbose(),
79+
(emitter, status_emitter::Gha { name, group: true }),
6580
)
6681
.unwrap();
6782
}

0 commit comments

Comments
 (0)