diff options
| author | Henrik Tjäder <henrik@tjaders.com> | 2025-06-25 20:56:00 +0200 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2025-07-02 18:34:20 +0000 |
| commit | 67730ceedbe231366bf2ad97faf22da8dd915ca2 (patch) | |
| tree | 92652acbb25130ebae4e30794a20d15f370ec9b8 /xtask | |
| parent | b4a0c9057df8df239edcd7c6bc2b5661868ef1bb (diff) | |
xtask: size: Store the expected output same as run
Diffstat (limited to 'xtask')
| -rw-r--r-- | xtask/src/argument_parsing.rs | 15 | ||||
| -rw-r--r-- | xtask/src/main.rs | 1 | ||||
| -rw-r--r-- | xtask/src/run.rs | 16 |
3 files changed, 27 insertions, 5 deletions
diff --git a/xtask/src/argument_parsing.rs b/xtask/src/argument_parsing.rs index ae73782..c8c0368 100644 --- a/xtask/src/argument_parsing.rs +++ b/xtask/src/argument_parsing.rs @@ -468,7 +468,7 @@ pub enum Commands { /// arguments will be passed on /// /// Example: `cargo xtask size -- -A` - Size(Arg), + Size(ArgsAndOverwrite), /// Run examples in QEMU and compare against expected output /// @@ -563,6 +563,19 @@ pub struct QemuAndRun { } #[derive(Debug, Parser, Clone)] +pub struct ArgsAndOverwrite { + /// If expected output is missing or mismatching, recreate the file + /// + /// This overwrites only missing or mismatching + #[arg(long)] + pub overwrite_expected: bool, + + /// Options to pass to `cargo <subcommand>` + #[command(subcommand)] + pub arguments: Option<ExtraArguments>, +} + +#[derive(Debug, Parser, Clone)] pub struct Arg { /// Options to pass to `cargo <subcommand>` #[command(subcommand)] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1702a8b..0b88337 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -317,6 +317,7 @@ fn main() -> anyhow::Result<()> { platform, backend, &examples_to_run, + args.overwrite_expected, &args.arguments, ) } diff --git a/xtask/src/run.rs b/xtask/src/run.rs index a1222d4..a769b20 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -68,6 +68,9 @@ fn command_parser( CargoCommand::Qemu { platform, example, .. } + | CargoCommand::ExampleSize { + platform, example, .. + } | CargoCommand::Run { platform, example, .. } => { @@ -108,7 +111,12 @@ fn command_parser( } let platform_name = platform.name(); - let run_file = format!("{example}.run"); + let run_file = if let CargoCommand::ExampleSize { .. } = *command { + format!("{example}.size") + } else { + format!("{example}.run") + }; + let expected_output_file = ["ci", "expected", &platform_name, &run_file] .iter() .collect::<PathBuf>() @@ -148,8 +156,7 @@ fn command_parser( | CargoCommand::Clippy { .. } | CargoCommand::Doc { .. } | CargoCommand::Test { .. } - | CargoCommand::Book { .. } - | CargoCommand::ExampleSize { .. } => { + | CargoCommand::Book { .. } => { let cargo_result = run_command(command, output_mode, true)?; Ok(cargo_result) } @@ -429,6 +436,7 @@ pub fn build_and_check_size<'c>( platform: Platforms, backend: Backends, examples: &'c [String], + overwrite: bool, arguments: &'c Option<ExtraArguments>, ) -> Vec<FinalRunResult<'c>> { info!("Measuring for platform: {platform:?}, backend: {backend:?}"); @@ -468,7 +476,7 @@ pub fn build_and_check_size<'c>( [cmd_build, cmd_size] }) - .map(|cmd| (globals, cmd, false)); + .map(|cmd| (globals, cmd, overwrite)); runner.run_and_coalesce() } |
