Skip to content

Commit e862383

Browse files
authored
Rollup merge of #87744 - Smittyvb:xpy-test-force-rerun, r=Mark-Simulacrum
Add x.py option to --force-rerun compiletest tests This can be used like `./x.py test src/test/ui/abi/ --force-rerun`, and is useful when verifying that newly blessed tests don't change between test runs (such as due to being dependent on the current time or memory layout or RNG), without needing to change the test file or find the right file in `build` to remove.
2 parents 508b328 + b7e9b1a commit e862383

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

src/bootstrap/builder/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ mod dist {
486486
fail_fast: true,
487487
doc_tests: DocTests::No,
488488
bless: false,
489+
force_rerun: false,
489490
compare_mode: None,
490491
rustfix_coverage: false,
491492
pass: None,
@@ -527,6 +528,7 @@ mod dist {
527528
fail_fast: true,
528529
doc_tests: DocTests::No,
529530
bless: false,
531+
force_rerun: false,
530532
compare_mode: None,
531533
rustfix_coverage: false,
532534
pass: None,
@@ -583,6 +585,7 @@ mod dist {
583585
fail_fast: true,
584586
doc_tests: DocTests::Yes,
585587
bless: false,
588+
force_rerun: false,
586589
compare_mode: None,
587590
rustfix_coverage: false,
588591
pass: None,

src/bootstrap/flags.rs

+10
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub enum Subcommand {
102102
paths: Vec<PathBuf>,
103103
/// Whether to automatically update stderr/stdout files
104104
bless: bool,
105+
force_rerun: bool,
105106
compare_mode: Option<String>,
106107
pass: Option<String>,
107108
run: Option<String>,
@@ -284,6 +285,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
284285
opts.optflag("", "no-doc", "do not run doc tests");
285286
opts.optflag("", "doc", "only run doc tests");
286287
opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests");
288+
opts.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged");
287289
opts.optopt(
288290
"",
289291
"compare-mode",
@@ -558,6 +560,7 @@ Arguments:
558560
"test" | "t" => Subcommand::Test {
559561
paths,
560562
bless: matches.opt_present("bless"),
563+
force_rerun: matches.opt_present("force-rerun"),
561564
compare_mode: matches.opt_str("compare-mode"),
562565
pass: matches.opt_str("pass"),
563566
run: matches.opt_str("run"),
@@ -726,6 +729,13 @@ impl Subcommand {
726729
}
727730
}
728731

732+
pub fn force_rerun(&self) -> bool {
733+
match *self {
734+
Subcommand::Test { force_rerun, .. } => force_rerun,
735+
_ => false,
736+
}
737+
}
738+
729739
pub fn rustfix_coverage(&self) -> bool {
730740
match *self {
731741
Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage,

src/bootstrap/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
13151315
cmd.arg("--bless");
13161316
}
13171317

1318+
if builder.config.cmd.force_rerun() {
1319+
cmd.arg("--force-rerun");
1320+
}
1321+
13181322
let compare_mode =
13191323
builder.config.cmd.compare_mode().or_else(|| {
13201324
if builder.config.test_compare_mode { self.compare_mode } else { None }

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ pub struct Config {
362362
pub nodejs: Option<String>,
363363
/// Path to a npm executable. Used for rustdoc GUI tests
364364
pub npm: Option<String>,
365+
366+
/// Whether to rerun tests even if the inputs are unchanged.
367+
pub force_rerun: bool,
365368
}
366369

367370
impl Config {

src/tools/compiletest/src/main.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
144144
"enable this to generate a Rustfix coverage file, which is saved in \
145145
`./<build_base>/rustfix_missing_coverage.txt`",
146146
)
147+
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
147148
.optflag("h", "help", "show this message")
148149
.reqopt("", "channel", "current Rust channel", "CHANNEL");
149150

@@ -289,6 +290,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
289290
llvm_components: matches.opt_str("llvm-components").unwrap(),
290291
nodejs: matches.opt_str("nodejs"),
291292
npm: matches.opt_str("npm"),
293+
294+
force_rerun: matches.opt_present("force-rerun"),
292295
}
293296
}
294297

@@ -644,13 +647,15 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test
644647
let test_name = crate::make_test_name(config, testpaths, revision);
645648
let mut desc = make_test_description(config, test_name, &test_path, src_file, cfg);
646649
// Ignore tests that already run and are up to date with respect to inputs.
647-
desc.ignore |= is_up_to_date(
648-
config,
649-
testpaths,
650-
&early_props,
651-
revision.map(|s| s.as_str()),
652-
inputs,
653-
);
650+
if !config.force_rerun {
651+
desc.ignore |= is_up_to_date(
652+
config,
653+
testpaths,
654+
&early_props,
655+
revision.map(|s| s.as_str()),
656+
inputs,
657+
);
658+
}
654659
test::TestDescAndFn { desc, testfn: make_test_closure(config, testpaths, revision) }
655660
})
656661
.collect()

0 commit comments

Comments
 (0)