1use camino::Utf8PathBuf;
4use clap::Parser;
5use test_runner_lib::{Binary, Config};
6
7#[derive(Parser, Debug)]
9#[command(version, about, long_about = None)]
10struct Args {
11 #[arg(long, env = "RUNNER_CRATE")]
12 package: String,
13
14 #[arg(long, env = "RUNNER_BINARY")]
15 binary: Utf8PathBuf,
16
17 #[arg(long, env = "RUNNER_CONFIG")]
18 config: Utf8PathBuf,
19
20 #[arg(long, env = "RUNNER_PROFILE")]
21 profile: String,
22
23 #[arg(long, env = "RUNNER_INSTA")]
24 insta: bool,
25
26 #[arg(long, env = "RUNNER_SOURCE_DIR")]
27 source_dir: Utf8PathBuf,
28
29 #[arg(long, env = "TEST_TMPDIR")]
30 tmp_dir: Utf8PathBuf,
31
32 #[arg(long, env = "XML_OUTPUT_FILE")]
33 xml_output_file: Option<Utf8PathBuf>,
34
35 #[arg(long, env = "TEST_TARGET")]
36 target: Option<String>,
37
38 #[arg(long, env = "TEST_UNDECLARED_OUTPUTS_DIR")]
39 test_output_dir: Option<Utf8PathBuf>,
40
41 #[arg(long, env = "VALGRIND")]
42 valgrind: Option<Utf8PathBuf>,
43
44 #[command(flatten)]
45 args: test_runner_lib::Args,
46}
47
48fn main() {
49 let args = Args::parse();
50
51 if let Some(valgrind) = args.valgrind {
52 unsafe {
54 std::env::set_var(
55 format!(
56 "CARGO_TARGET_{}_RUNNER",
57 target_spec::Platform::build_target()
58 .unwrap()
59 .triple_str()
60 .to_ascii_uppercase()
61 .replace("-", "_")
62 ),
63 format!(
64 "{valgrind} --error-exitcode=1 --leak-check=full --show-leak-kinds=definite --errors-for-leak-kinds=definite --track-origins=yes"
65 ),
66 );
67 }
68 }
69
70 test_runner_lib::run_nextest(Config {
71 config_path: args.config,
72 package: args.package.clone(),
73 profile: args.profile,
74 tmp_dir: args.tmp_dir,
75 xml_output_file: args.xml_output_file,
76 args: args.args,
77 insta: args.insta,
78 source_dir: args.source_dir,
79 test_output_dir: args.test_output_dir,
80 binaries: vec![Binary {
81 name: args.target.unwrap_or(args.package),
82 path: args.binary,
83 }],
84 });
85}