Skip to content
Myr

Add migration guidance for removed --reference option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 6dddb02 · Browse files · 2 files+32 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+32 added−0 removed

  • tests:+19 added−0 removed
  • other:+13 added−0 removed

2 files+32 added−0 removed

modified:src/cli.rs+13 added
48 unmodified lines
49 .action(ArgAction::Append)50 .value_hint(ValueHint::CommandString)51 .value_parser(NonEmptyStringValueParser::new()),52 )53 // Retain the removed option to provide migration guidance for old invocations.54 .arg(55 Arg::new("reference")56 .long("reference")57 .hide(true)58 .value_name("CMD")59 .num_args(0..=1)60 .default_missing_value("")61 .value_parser(|_: &str| -> Result<String, String> {62 Err("The --reference option has been removed. Put your reference command first instead.".into())63 })64 .help("Removed: put your reference command first instead."),65 )66 .arg(67 Arg::new("metrics")68 .long("metrics")69 .value_name("PRESET|METRIC[:UNIT],…")70 .default_value("default")
389 unmodified lines
modified:tests/integration_tests.rs+19 added
43 unmodified lines
44 .success();45}4647#[test]48fn rejects_removed_reference_option_with_migration_guidance() {49 for args in [50 vec!["--reference", "echo reference", "echo comparison"],51 vec!["echo comparison", "--reference=echo reference"],52 vec!["--reference", "echo reference"],53 vec!["--reference"],54 ] {55 hyperfine()56 .args(args)57 .assert()58 .code(2)59 .stdout("")60 .stderr(predicate::str::contains(61 "The --reference option has been removed. Put your reference command first instead.",62 ));63 }64}6566#[test]67fn one_run_is_supported() {68 hyperfine()69 .arg("--runs=1")70 .arg("echo dummy benchmark")
1319 unmodified lines