|
| 1 | +# `report-time` |
| 2 | + |
| 3 | +The tracking issue for this feature is: [#64888] |
| 4 | + |
| 5 | +[#64888]: https://github.com/rust-lang/rust/issues/64888 |
| 6 | + |
| 7 | +------------------------ |
| 8 | + |
| 9 | +The `report-time` feature adds a possibility to report execution time of the |
| 10 | +tests generated via `libtest`. |
| 11 | + |
| 12 | +This is unstable feature, so you have to provide `-Zunstable-options` to get |
| 13 | +this feature working. |
| 14 | + |
| 15 | +Sample usage command: |
| 16 | + |
| 17 | +```sh |
| 18 | +./test_executable -Zunstable-options --report-time |
| 19 | +``` |
| 20 | + |
| 21 | +Available options: |
| 22 | + |
| 23 | +```sh |
| 24 | +--report-time [plain|colored] |
| 25 | + Show execution time of each test. Awailable values: |
| 26 | + plain = do not colorize the execution time (default); |
| 27 | + colored = colorize output according to the `color` |
| 28 | + parameter value; |
| 29 | + Threshold values for colorized output can be |
| 30 | + configured via |
| 31 | + `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` |
| 32 | + and |
| 33 | + `RUST_TEST_TIME_DOCTEST` environment variables. |
| 34 | + Expected format of environment variable is |
| 35 | + `VARIABLE=WARN_TIME,CRITICAL_TIME`. |
| 36 | + Not available for --format=terse |
| 37 | +--ensure-time |
| 38 | + Treat excess of the test execution time limit as |
| 39 | + error. |
| 40 | + Threshold values for this option can be configured via |
| 41 | + `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` |
| 42 | + and |
| 43 | + `RUST_TEST_TIME_DOCTEST` environment variables. |
| 44 | + Expected format of environment variable is |
| 45 | + `VARIABLE=WARN_TIME,CRITICAL_TIME`. |
| 46 | + `CRITICAL_TIME` here means the limit that should not be |
| 47 | + exceeded by test. |
| 48 | +``` |
| 49 | + |
| 50 | +Example of the environment variable format: |
| 51 | + |
| 52 | +```sh |
| 53 | +RUST_TEST_TIME_UNIT=100,200 |
| 54 | +``` |
| 55 | + |
| 56 | +where 100 stands for warn time, and 200 stands for critical time. |
| 57 | + |
| 58 | +## Examples |
| 59 | + |
| 60 | +```sh |
| 61 | +cargo test --tests -- -Zunstable-options --report-time |
| 62 | + Finished dev [unoptimized + debuginfo] target(s) in 0.02s |
| 63 | + Running target/debug/deps/example-27fb188025bec02c |
| 64 | + |
| 65 | +running 3 tests |
| 66 | +test tests::unit_test_quick ... ok <0.000s> |
| 67 | +test tests::unit_test_warn ... ok <0.055s> |
| 68 | +test tests::unit_test_critical ... ok <0.110s> |
| 69 | + |
| 70 | +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out |
| 71 | + |
| 72 | + Running target/debug/deps/tests-cedb06f6526d15d9 |
| 73 | + |
| 74 | +running 3 tests |
| 75 | +test unit_test_quick ... ok <0.000s> |
| 76 | +test unit_test_warn ... ok <0.550s> |
| 77 | +test unit_test_critical ... ok <1.100s> |
| 78 | + |
| 79 | +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out |
| 80 | +``` |
0 commit comments