-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libtest: Print the total time taken to execute a test suite #75752
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
library/test/src/time.rs
Outdated
|
||
impl fmt::Display for TestSuiteExecTime { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{:.1}s", self.0.as_secs_f64()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what's the best precision here, .1
seems a bit to coarse-grained here. Cargo uses two decimal digits ( Finished test [unoptimized] target(s) in 3.91s
), so let's do this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
Small problem: The default width of my terminal is 80. The width of Bigger problem: There are two tests ( |
I think libtest already assumes wider than 80 terminal:
I am not familiar enough with compiletest, but a nuclear option would be a |
Setting the time to zero sounds reasonable. The documentation says rustc is run with |
I found no clues in the source code that this is possible. Therefore I implemented
|
Great idea; that sounds very useful! I think a better way to fix the "test output" problem is to use custom normalization of the output, as described here. I haven't looked into it in detail, but it seems like we can regex-replace the actual output before it is compared to the And I think the output should say something like |
cb1f9e6
to
731566a
Compare
Normalization works great! I also changed the output as proposed, this helped to find the text that needs to be normalized.
|
Yet another failing test: Possible solutions:
Any advice? |
Looks much better now! The second test failure is unfortunate. I am not sure how to best fix this :/ But in general, I'm not sure I am the correct person to review this (doesn't seem like a libs issue). Maaaybe @rust-lang/devtools can help out? |
I suspect that normalizing the JSON output shouldn't be too hard -- we can use anything on CI, probably, but something liked |
731566a
to
4c76122
Compare
Thanks, I fixed the test with And yes, |
4c76122
to
f8d0857
Compare
I would say libtest is a libs team concern |
Well then! @bors r+ Thanks again for the PR! |
📌 Commit f8d0857135c216621c39edefbb2ecddb26d2208a has been approved by |
This is not gated, right? Then this should hit relnotes |
⌛ Testing commit f8d0857135c216621c39edefbb2ecddb26d2208a with merge 9d4918d9118417d0a46db7131fc474ec0ac3ee9b... |
💔 Test failed - checks-actions |
Spurious error:
@bors retry |
⌛ Testing commit fe3daea10414fd9ba1e956ee1bcf23db07c8a7c2 with merge ed9f6cafa75fbe0e18198e6fabcdf75e7d5e1b1e... |
💔 Test failed - checks-actions |
Oh, apparently POSIX doesn't even require I think this would work: sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' |
fe3daea
to
322f53d
Compare
@m-ou-se Thanks, I changed the latest commit accordingly. |
📌 Commit 322f53d has been approved by |
☀️ Test successful - checks-actions |
Thanks for the help! |
@jakoschiko Thanks for all your work to make this happen! |
… r=alexcrichton Relaxes expectation of `cargo test` tests to accept test execution time rust-lang/rust#75752 changes the output of libtest. For example, output before: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` Output after: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s ``` This breaks some cargo tests: https://github.com/rust-lang-ci/rust/runs/1439245145 As a preparation for the merge, this PR relaxes the test expectations of `cargo test` tests to accept both outputs. I'm using the existing pattern feature of `Execs::with_stdout`: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..] ``` I made this change for the following tests: - `test::can_not_mix_doc_tests_and_regular_tests` - `test::cargo_test_quiet_with_harness` - `test::test_filtered_excludes_compiling_examples` - `test::cargo_test_doctest_xcompile_ignores` (didn't fail in rust-lang/rust#79317, but failed locally) - `test::cargo_test_doctest_xcompile` (doesn't run locally, I changed it just to be safe) - `test::cargo_test_doctest_xcompile_runner` (doesn't run locally, I changed it just to be safe) - `test::cargo_test_doctest_xcompile_no_runner` (doesn't run locally, I changed it just to be safe) If requested, I will open another PR later to change the expectation to: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [..]s ``` However, I don't know how to handle WASM targets because WASM doesn't support time measuring, therefore the libtest output didn't change for WASM. Is WASM even relevant here?
Pkgsrc changes: * Adjust patches, re-compute line offsets, fix capitalization. * Remove i686/FreeBSD support, no longer provided upstream. * Bump bootstraps to 1.49.0. * Change USE_TOOLS from bsdtar to gtar. * Reduce diffs to pkgsrc-wip package patches. * Allow rust.BUILD_TARGET to override automatic choice of target. * Add an i586/NetBSD (pentium) bootstrap variant (needs testing), not yet added as bootstrap since 1.49 doesn't have that variant. Upstream changes: Version 1.50.0 (2021-02-11) ============================ Language ----------------------- - [You can now use `const` values for `x` in `[x; N]` array expressions.][79270] This has been technically possible since 1.38.0, as it was unintentionally stabilized. - [Assignments to `ManuallyDrop<T>` union fields are now considered safe.][78068] Compiler ----------------------- - [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142] - [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484] - [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484] \* Refer to Rust's [platform support page][forge-platform-support] for more information on Rust's tiered platform support. Libraries ----------------------- - [`proc_macro::Punct` now implements `PartialEq<char>`.][78636] - [`ops::{Index, IndexMut}` are now implemented for fixed sized arrays of any length.][74989] - [On Unix platforms, the `std::fs::File` type now has a "niche" of `-1`.][74699] This value cannot be a valid file descriptor, and now means `Option<File>` takes up the same amount of space as `File`. Stabilized APIs --------------- - [`bool::then`] - [`btree_map::Entry::or_insert_with_key`] - [`f32::clamp`] - [`f64::clamp`] - [`hash_map::Entry::or_insert_with_key`] - [`Ord::clamp`] - [`RefCell::take`] - [`slice::fill`] - [`UnsafeCell::get_mut`] The following previously stable methods are now `const`. - [`IpAddr::is_ipv4`] - [`IpAddr::is_ipv6`] - [`Layout::size`] - [`Layout::align`] - [`Layout::from_size_align`] - `pow` for all integer types. - `checked_pow` for all integer types. - `saturating_pow` for all integer types. - `wrapping_pow` for all integer types. - `next_power_of_two` for all unsigned integer types. - `checked_power_of_two` for all unsigned integer types. Cargo ----------------------- - [Added the `[build.rustc-workspace-wrapper]` option.][cargo/8976] This option sets a wrapper to execute instead of `rustc`, for workspace members only. - [`cargo:rerun-if-changed` will now, if provided a directory, scan the entire contents of that directory for changes.][cargo/8973] - [Added the `--workspace` flag to the `cargo update` command.][cargo/8725] Misc ---- - [The search results tab and the help button are focusable with keyboard in rustdoc.][79896] - [Running tests will now print the total time taken to execute.][75752] Compatibility Notes ------------------- - [The `compare_and_swap` method on atomics has been deprecated.][79261] It's recommended to use the `compare_exchange` and `compare_exchange_weak` methods instead. - [Changes in how `TokenStream`s are checked have fixed some cases where you could write unhygenic `macro_rules!` macros.][79472] - [`#![test]` as an inner attribute is now considered unstable like other inner macro attributes, and reports an error by default through the `soft_unstable` lint.][79003] - [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864] - [Dropped support for all cloudabi targets.][78439] - [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's recommended to use the `#[panic_handler]` attribute to provide your own implementation. - [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296] [74989]: rust-lang/rust#74989 [79261]: rust-lang/rust#79261 [79896]: rust-lang/rust#79896 [79484]: rust-lang/rust#79484 [79472]: rust-lang/rust#79472 [79270]: rust-lang/rust#79270 [79003]: rust-lang/rust#79003 [78864]: rust-lang/rust#78864 [78636]: rust-lang/rust#78636 [78439]: rust-lang/rust#78439 [78343]: rust-lang/rust#78343 [78296]: rust-lang/rust#78296 [78068]: rust-lang/rust#78068 [75752]: rust-lang/rust#75752 [74699]: rust-lang/rust#74699 [78142]: rust-lang/rust#78142 [77484]: rust-lang/rust#77484 [cargo/8976]: rust-lang/cargo#8976 [cargo/8973]: rust-lang/cargo#8973 [cargo/8725]: rust-lang/cargo#8725 [`IpAddr::is_ipv4`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv4 [`IpAddr::is_ipv6`]: https://doc.rust-lang.org/stable/std/net/enum.IpAddr.html#method.is_ipv6 [`Layout::align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.align [`Layout::from_size_align`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.from_size_align [`Layout::size`]: https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.size [`Ord::clamp`]: https://doc.rust-lang.org/stable/std/cmp/trait.Ord.html#method.clamp [`RefCell::take`]: https://doc.rust-lang.org/stable/std/cell/struct.RefCell.html#method.take [`UnsafeCell::get_mut`]: https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.get_mut [`bool::then`]: https://doc.rust-lang.org/stable/std/primitive.bool.html#method.then [`btree_map::Entry::or_insert_with_key`]: https://doc.rust-lang.org/stable/std/collections/btree_map/enum.Entry.html#method.or_insert_with_key [`f32::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.clamp [`f64::clamp`]: https://doc.rust-lang.org/stable/std/primitive.f64.html#method.clamp [`hash_map::Entry::or_insert_with_key`]: https://doc.rust-lang.org/stable/std/collections/hash_map/enum.Entry.html#method.or_insert_with_key [`slice::fill`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.fill
Print the total time taken to execute a test suite by default, without any kind of flag.
Closes #75660
Example