-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for report-time
#64888
Comments
I propose that the methods for enabling and configuring this option be changed. The option currently uses I propose:
Do others have opinions? |
Essentially, what is described here: rust-lang#64888 (comment) There is one difference. The comment proposes to add a `--report-time-color` option. This change instead uses libtest's existing `--color` option for that purpose.
Use `optflag` for `--report-time` Essentially, what is described here: rust-lang#64888 (comment) There is one difference. The comment proposes to add a `--report-time-color` option. This change instead uses libtest's existing `--color` option for that purpose.
Use `optflag` for `--report-time` Essentially, what is described here: rust-lang#64888 (comment) There is one difference. The comment proposes to add a `--report-time-color` option. This change instead uses libtest's existing `--color` option for that purpose.
Note that cargo stabilized |
Hoping this can get released to stable soon now that |
I was trying this out to focus on some slow tests. One small feedback: according to ehuss in #115989 the times are measured in milliseconds, but the doc https://doc.rust-lang.org/beta/unstable-book/compiler-flags/report-time.html and help strings don't specify the units. However, beyond that, I can see that With
Great, that failed as it should have. But on an integration test:
Even the tests that take much longer than either limit don't fail, and they aren't colored or highlighted either. |
I've been trying |
I tested it with the most recent compiler and it worked for me. > cargo +nightly --version
cargo 1.78.0-nightly (ccc84ccec 2024-02-07)
> tree -I target
.
├── Cargo.lock
├── Cargo.toml
├── src
│ └── lib.rs
└── tests
└── example.rs
> cat tests/example.rs
#[test]
fn integration_test_fast() {
std::thread::sleep(std::time::Duration::from_millis(12))
}
#[test]
fn integration_test_slow() {
std::thread::sleep(std::time::Duration::from_millis(1234))
}
#[test]
fn integration_test_very_slow() {
std::thread::sleep(std::time::Duration::from_millis(12345))
}
> env RUST_TEST_TIME_INTEGRATION=50,100 RUST_TEST_TIME_UNIT=50,100 cargo +nightly test --test example -- -Zunstable-options --report-time --ensure-time
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running tests/example.rs (target/debug/deps/example-cc2e736b09617b55)
running 3 tests
test integration_test_fast ... ok <0.012s>
test integration_test_slow ... FAILED (time limit exceeded) <1.234s>
test integration_test_very_slow ... FAILED (time limit exceeded) <12.345s>
failures (time limit exceeded):
failures (time limit exceeded):
integration_test_slow
integration_test_very_slow
test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.35s
error: test failed, to rerun pass `--test example` I suggest creating an issue with a minimal example. If you mention me, I'll dig into it. |
The |
@jakoschiko I made a small reproduction similar to yours and it works as expected:
However, when I try the exact same command in the cargo-mutants repo, it shows the times but it does not flag any failures. It's very surprising. I don't think mutants is doing anything especially strange to interfere with the normal working of the test harness.
As you can see some of these tests took much longer than the limit... I wondered if it was something about running multiple threads in parallel throwing off the timing, so I tried with So, I don't know how to minimize it, but you should at least be able to reproduce this from the cargo-mutants public repo. |
Can confirm, will investigate. |
@sourcefrog Your repository doesn't have any integration tests :p Usually an integration test has a path like this:
In your case the path looks like this:
This in neither documented here nor here. Surprisingly it does work, but the implementation of the if crate_path.ends_with("src") {
// `/src` folder contains unit-tests.
TestType::UnitTest
} else if crate_path.ends_with("tests") {
// `/tests` folder contains integration tests.
TestType::IntegrationTest
} else {
// Crate layout doesn't match expected one, test type is unknown.
TestType::Unknown
} So technically |
Fascinating, well found. `cargo metadata` and `cargo test` see it as a test
target, but you're quite right it doesn't match what the docs specify,
which is that they need to be directly within `tests`.
|
Tracks stabilization for the
report-time
andensure-test-time
libtest
options.The text was updated successfully, but these errors were encountered: