forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#99939 - saethlin:pre-sort-tests, r=thomcc,j…
…ackh726 Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
- Loading branch information
Showing
10 changed files
with
130 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#![feature(prelude_import)] | ||
#![no_std] | ||
#[prelude_import] | ||
use ::std::prelude::rust_2015::*; | ||
#[macro_use] | ||
extern crate std; | ||
// compile-flags: --crate-type=lib --test | ||
// pretty-compare-only | ||
// pretty-mode:expanded | ||
// pp-exact:tests-are-sorted.pp | ||
|
||
extern crate test; | ||
#[cfg(test)] | ||
#[rustc_test_marker = "m_test"] | ||
pub const m_test: test::TestDescAndFn = | ||
test::TestDescAndFn { | ||
desc: test::TestDesc { | ||
name: test::StaticTestName("m_test"), | ||
ignore: false, | ||
ignore_message: ::core::option::Option::None, | ||
compile_fail: false, | ||
no_run: false, | ||
should_panic: test::ShouldPanic::No, | ||
test_type: test::TestType::Unknown, | ||
}, | ||
testfn: test::StaticTestFn(|| test::assert_test_result(m_test())), | ||
}; | ||
fn m_test() {} | ||
|
||
extern crate test; | ||
#[cfg(test)] | ||
#[rustc_test_marker = "z_test"] | ||
pub const z_test: test::TestDescAndFn = | ||
test::TestDescAndFn { | ||
desc: test::TestDesc { | ||
name: test::StaticTestName("z_test"), | ||
ignore: false, | ||
ignore_message: ::core::option::Option::None, | ||
compile_fail: false, | ||
no_run: false, | ||
should_panic: test::ShouldPanic::No, | ||
test_type: test::TestType::Unknown, | ||
}, | ||
testfn: test::StaticTestFn(|| test::assert_test_result(z_test())), | ||
}; | ||
fn z_test() {} | ||
|
||
extern crate test; | ||
#[cfg(test)] | ||
#[rustc_test_marker = "a_test"] | ||
pub const a_test: test::TestDescAndFn = | ||
test::TestDescAndFn { | ||
desc: test::TestDesc { | ||
name: test::StaticTestName("a_test"), | ||
ignore: false, | ||
ignore_message: ::core::option::Option::None, | ||
compile_fail: false, | ||
no_run: false, | ||
should_panic: test::ShouldPanic::No, | ||
test_type: test::TestType::Unknown, | ||
}, | ||
testfn: test::StaticTestFn(|| test::assert_test_result(a_test())), | ||
}; | ||
fn a_test() {} | ||
#[rustc_main] | ||
pub fn main() -> () { | ||
extern crate test; | ||
test::test_main_static(&[&a_test, &m_test, &z_test]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// compile-flags: --crate-type=lib --test | ||
// pretty-compare-only | ||
// pretty-mode:expanded | ||
// pp-exact:tests-are-sorted.pp | ||
|
||
#[test] | ||
fn m_test() {} | ||
|
||
#[test] | ||
fn z_test() {} | ||
|
||
#[test] | ||
fn a_test() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters