Skip to content
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

Rollup of 8 pull requests #94072

Merged
merged 18 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6fd5cf5
Add documentation to more `From::from` implementations.
kpreid Oct 13, 2021
96d96a7
Use `optflag` for `--report-time`
smoelius Jan 30, 2022
d9592d9
Fix suggestion to slice if scurtinee is a reference to `Result` or `O…
ChayimFriedman2 Feb 14, 2022
8610edd
Suggest deriving required supertraits
rukai Feb 6, 2022
ae21240
Make implementation generic
rukai Feb 12, 2022
1973f27
Cleanup uses
rukai Feb 16, 2022
91adb6c
Correctly mark the span of captured arguments in `format_args!()`
ChayimFriedman2 Feb 16, 2022
6d2cdbe
Add mentions to `Copy` for `union` fields
danielhenrymantilla Feb 15, 2022
65fc705
Do not suggest "is a function" for free variables
notriddle Feb 13, 2022
8630085
Update dist-x86_64-musl to Ubuntu 20.04
nikic Feb 16, 2022
1cc0ae4
Rollup merge of #89869 - kpreid:from-doc, r=yaahc
matthiaskrgr Feb 17, 2022
d855121
Rollup merge of #93479 - smoelius:master, r=yaahc
matthiaskrgr Feb 17, 2022
351aa1b
Rollup merge of #93693 - rukai:91550, r=davidtwco
matthiaskrgr Feb 17, 2022
2c0df80
Rollup merge of #93981 - ChayimFriedman2:slice-pat-reference-option-r…
matthiaskrgr Feb 17, 2022
3e72705
Rollup merge of #93996 - notriddle:notriddle/magically-becomes-a-func…
matthiaskrgr Feb 17, 2022
a1a750b
Rollup merge of #94030 - ChayimFriedman2:issue-94010, r=petrochenkov
matthiaskrgr Feb 17, 2022
91f70a8
Rollup merge of #94031 - danielhenrymantilla:diagnostics/union-drop-s…
matthiaskrgr Feb 17, 2022
aa83189
Rollup merge of #94064 - nikic:update-musl-image, r=Mark-Simulacrum
matthiaskrgr Feb 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions library/test/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ fn optgroups() -> getopts::Options {
unstable-options = Allow use of experimental features",
"unstable-options",
)
.optflagopt(
.optflag(
"",
"report-time",
"Show execution time of each test. Available values:
plain = do not colorize the execution time (default);
colored = colorize output according to the `color` parameter value;
"Show execution time of each test.

Threshold values for colorized output can be configured via
`RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` and
Expand All @@ -125,7 +123,6 @@ fn optgroups() -> getopts::Options {
is 0.5 seconds, and the critical time is 2 seconds.

Not available for --format=terse",
"plain|colored",
)
.optflag(
"",
Expand Down Expand Up @@ -319,17 +316,12 @@ fn get_time_options(
allow_unstable: bool,
) -> OptPartRes<Option<TestTimeOptions>> {
let report_time = unstable_optflag!(matches, allow_unstable, "report-time");
let colored_opt_str = matches.opt_str("report-time");
let mut report_time_colored = report_time && colored_opt_str == Some("colored".into());
let ensure_test_time = unstable_optflag!(matches, allow_unstable, "ensure-time");

// If `ensure-test-time` option is provided, time output is enforced,
// so user won't be confused if any of tests will silently fail.
let options = if report_time || ensure_test_time {
if ensure_test_time && !report_time {
report_time_colored = true;
}
Some(TestTimeOptions::new_from_env(ensure_test_time, report_time_colored))
Some(TestTimeOptions::new_from_env(ensure_test_time))
} else {
None
};
Expand Down
2 changes: 1 addition & 1 deletion library/test/src/formatters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<T: Write> PrettyFormatter<T> {
if let (Some(opts), Some(time)) = (self.time_options, exec_time) {
let time_str = format!(" <{}>", time);

let color = if opts.colored {
let color = if self.use_color {
if opts.is_critical(desc, time) {
Some(term::color::RED)
} else if opts.is_warn(desc, time) {
Expand Down
1 change: 0 additions & 1 deletion library/test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ fn test_time_options_threshold() {

let options = TestTimeOptions {
error_on_excess: false,
colored: false,
unit_threshold: unit.clone(),
integration_threshold: integration.clone(),
doctest_threshold: doc.clone(),
Expand Down
5 changes: 2 additions & 3 deletions library/test/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ pub struct TestTimeOptions {
/// Denotes if the test critical execution time limit excess should be considered
/// a test failure.
pub error_on_excess: bool,
pub colored: bool,
pub unit_threshold: TimeThreshold,
pub integration_threshold: TimeThreshold,
pub doctest_threshold: TimeThreshold,
}

impl TestTimeOptions {
pub fn new_from_env(error_on_excess: bool, colored: bool) -> Self {
pub fn new_from_env(error_on_excess: bool) -> Self {
let unit_threshold = TimeThreshold::from_env_var(time_constants::UNIT_ENV_NAME)
.unwrap_or_else(Self::default_unit);

Expand All @@ -155,7 +154,7 @@ impl TestTimeOptions {
let doctest_threshold = TimeThreshold::from_env_var(time_constants::DOCTEST_ENV_NAME)
.unwrap_or_else(Self::default_doctest);

Self { error_on_excess, colored, unit_threshold, integration_threshold, doctest_threshold }
Self { error_on_excess, unit_threshold, integration_threshold, doctest_threshold }
}

pub fn is_warn(&self, test: &TestDesc, exec_time: &TestExecTime) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Controls the format of the output. Valid options:

Writes the results of the tests to the given file.

#### `--report-time` _FORMAT_
#### `--report-time`

⚠️ 🚧 This option is [unstable](#unstable-options), and requires the `-Z
unstable-options` flag. See [tracking issue
Expand Down
7 changes: 2 additions & 5 deletions src/doc/unstable-book/src/compiler-flags/report-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ Sample usage command:
Available options:

```sh
--report-time [plain|colored]
Show execution time of each test. Available values:
plain = do not colorize the execution time (default);
colored = colorize output according to the `color`
parameter value;
--report-time
Show execution time of each test.
Threshold values for colorized output can be
configured via
`RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION`
Expand Down