Skip to content

Commit 67730ce

Browse files
AfoHTkorken89
authored andcommitted
xtask: size: Store the expected output same as run
1 parent b4a0c90 commit 67730ce

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

xtask/src/argument_parsing.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ pub enum Commands {
468468
/// arguments will be passed on
469469
///
470470
/// Example: `cargo xtask size -- -A`
471-
Size(Arg),
471+
Size(ArgsAndOverwrite),
472472

473473
/// Run examples in QEMU and compare against expected output
474474
///
@@ -562,6 +562,19 @@ pub struct QemuAndRun {
562562
pub overwrite_expected: bool,
563563
}
564564

565+
#[derive(Debug, Parser, Clone)]
566+
pub struct ArgsAndOverwrite {
567+
/// If expected output is missing or mismatching, recreate the file
568+
///
569+
/// This overwrites only missing or mismatching
570+
#[arg(long)]
571+
pub overwrite_expected: bool,
572+
573+
/// Options to pass to `cargo <subcommand>`
574+
#[command(subcommand)]
575+
pub arguments: Option<ExtraArguments>,
576+
}
577+
565578
#[derive(Debug, Parser, Clone)]
566579
pub struct Arg {
567580
/// Options to pass to `cargo <subcommand>`

xtask/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ fn main() -> anyhow::Result<()> {
317317
platform,
318318
backend,
319319
&examples_to_run,
320+
args.overwrite_expected,
320321
&args.arguments,
321322
)
322323
}

xtask/src/run.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ fn command_parser(
6868
CargoCommand::Qemu {
6969
platform, example, ..
7070
}
71+
| CargoCommand::ExampleSize {
72+
platform, example, ..
73+
}
7174
| CargoCommand::Run {
7275
platform, example, ..
7376
} => {
@@ -108,7 +111,12 @@ fn command_parser(
108111
}
109112

110113
let platform_name = platform.name();
111-
let run_file = format!("{example}.run");
114+
let run_file = if let CargoCommand::ExampleSize { .. } = *command {
115+
format!("{example}.size")
116+
} else {
117+
format!("{example}.run")
118+
};
119+
112120
let expected_output_file = ["ci", "expected", &platform_name, &run_file]
113121
.iter()
114122
.collect::<PathBuf>()
@@ -148,8 +156,7 @@ fn command_parser(
148156
| CargoCommand::Clippy { .. }
149157
| CargoCommand::Doc { .. }
150158
| CargoCommand::Test { .. }
151-
| CargoCommand::Book { .. }
152-
| CargoCommand::ExampleSize { .. } => {
159+
| CargoCommand::Book { .. } => {
153160
let cargo_result = run_command(command, output_mode, true)?;
154161
Ok(cargo_result)
155162
}
@@ -429,6 +436,7 @@ pub fn build_and_check_size<'c>(
429436
platform: Platforms,
430437
backend: Backends,
431438
examples: &'c [String],
439+
overwrite: bool,
432440
arguments: &'c Option<ExtraArguments>,
433441
) -> Vec<FinalRunResult<'c>> {
434442
info!("Measuring for platform: {platform:?}, backend: {backend:?}");
@@ -468,7 +476,7 @@ pub fn build_and_check_size<'c>(
468476

469477
[cmd_build, cmd_size]
470478
})
471-
.map(|cmd| (globals, cmd, false));
479+
.map(|cmd| (globals, cmd, overwrite));
472480

473481
runner.run_and_coalesce()
474482
}

0 commit comments

Comments
 (0)