-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
RUST_TEST_TIME_INTEGRATION and RUST_TEST_TIME_UNIT ignored #115989
Comments
The environment variables require extra CLI options in order to enable them. For example:
There's more information in the documentation at https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/report-time.html. |
Thank you for looking it up Eric. Good to have met you at RustConf in Albuquerque. Unfortunately, that doesn't make the "60 seconds" warning/notice go away: cargo test --tests -- -Zunstable-options --ensure-time
Compiling test_timeout_rs v0.1.0 (/share/pkehl/GIT/test_timeout_rs)
Finished test [unoptimized + debuginfo] target(s) in 1.07s
Running unittests src/lib.rs (target/debug/deps/test_timeout_rs-ccebbdfa21928176)
running 1 test
test unit_test::long_unit_test has been running for over 60 seconds
test unit_test::long_unit_test ... ok <62.000s>
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s
Running tests/integration.rs (target/debug/deps/integration-f2beccbd60895674)
running 1 test
test long_unit_test has been running for over 60 seconds
test long_unit_test ... ok <62.000s>
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s (With the same |
The same problem with export RUST_TEST_TIME_UNIT=3600000,3600000
export RUST_TEST_TIME_INTEGRATION=3600000,3600000 and it reports if over 60 seconds. Related to/for #64888. |
It was good to meet you too! Can you make sure the environment variable is set in your second attempt? It seems to work for me:
Note that it is expected for it to print a warning after 60 seconds (that's what the first threshold defines), and then it should fail after it is done. |
Still the same. (Side note: I've renamed the integration test function to RUST_TEST_TIME_INTEGRATION=3600000,3600000 cargo test --tests -- -Zunstable-options --ensure-time
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running unittests src/lib.rs (target/debug/deps/test_timeout_rs-ccebbdfa21928176)
running 1 test
test unit_test::long_unit_test has been running for over 60 seconds
test unit_test::long_unit_test ... ok <62.000s>
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s
Running tests/integration.rs (target/debug/deps/integration-f2beccbd60895674)
running 1 test
test long_integration_test has been running for over 60 seconds
test long_integration_test ... ok <62.000s>
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s I believe I have an ordinary ps
PID TTY TIME CMD
518178 pts/4 00:00:00 bash
518422 pts/4 00:00:00 ps
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
env | grep RUST
RUST_TEST_TIME_UNIT=3600000,3600000
RUST_TEST_TIME_INTEGRATION=3600000,3600000
uname -a
Linux spectre 6.6.0-1-MANJARO #3 SMP PREEMPT_DYNAMIC Mon Sep 11 12:25:45 CEST 2023 x86_64 GNU/Linux What can be different? |
Oh, I see, I only set RUST_TEST_TIME_INTEGRATION, but not RUST_TEST_TIME_UNIT. Two things:
|
Still the same problem here ("has been running for over 60 seconds" reported), even if I set My goal: to suppress these warnings (for long tests). For example, from the following I'd expect a warning only if the test runs for over 1 hour, and an error/critical if it runs for over 10 hours. RUST_TEST_TIME_INTEGRATION=3600000,36000000 cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.04s
Running unittests src/lib.rs (target/debug/deps/test_timeout_rs-ccebbdfa21928176)
running 1 test
test unit_test::long_unit_test has been running for over 60 seconds
test unit_test::long_unit_test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s
Running tests/integration.rs (target/debug/deps/integration-f2beccbd60895674)
running 1 test
test long_integration_test has been running for over 60 seconds
test long_integration_test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 62.00s
Doc-tests test_timeout_rs
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s |
The "has been running for over 60 seconds" message is unrelated to the |
Thank you Eric. |
The below defected/unimplemented feature is NOT documented in Cargo book, but it's in the public & documented interface of
library/test/src/time.rs
and its submoduletime_constants
(even though it may be accessible from Rust tools only).https://github.com/rust-lang/rust/blob/41bafc4ff3eb6a73aa40e60c3bd4494302c7ec57/library/test/src/time.rs#L31C38-L31C57 and https://github.com/rust-lang/rust/blob/41bafc4ff3eb6a73aa40e60c3bd4494302c7ec57/library/test/src/time.rs#L38C45-L38C71 suggest that unit tests use
RUST_TEST_TIME_UNIT, and integration tests use
RUST_TEST_TIME_INTEGRATION` (despite a 2x copy-and-paste mistake of mentioning "threshold for unit-tests" for integration and doc tests).However, neither
RUST_TEST_TIME_UNIT
norRUST_TEST_TIME_INTEGRATION
seems to have any effect.As per
rust/library/test/src/time.rs
Line 106 in 41bafc4
from_env_var(&str)
:With https://github.com/peter-kehl/test_timeout_rs:
cargo test
still reports "test ... has been running for over 60 seconds" - for both unit tests and integration tests.The text was updated successfully, but these errors were encountered: