Skip to content

Commit 49023e1

Browse files
authored
Merge pull request #3214 from rbtcollins/test-up-aliases
Work improving check_updates_none test performance
2 parents 2eeef66 + fa91396 commit 49023e1

File tree

5 files changed

+65
-12
lines changed

5 files changed

+65
-12
lines changed

tests/cli-exact.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ fn check_updates_none() {
167167
expect_ok(config, &["rustup", "update", "stable"]);
168168
expect_ok(config, &["rustup", "update", "beta"]);
169169
expect_ok(config, &["rustup", "update", "nightly"]);
170-
expect_ok(config, &["rustup", "upgrade", "stable"]);
171-
expect_ok(config, &["rustup", "upgrade", "beta"]);
172-
expect_ok(config, &["rustup", "upgrade", "nightly"]);
173-
expect_ok(config, &["rustup", "up", "stable"]);
174-
expect_ok(config, &["rustup", "up", "beta"]);
175-
expect_ok(config, &["rustup", "up", "nightly"]);
176170
expect_stdout_ok(
177171
config,
178172
&["rustup", "check"],
@@ -193,9 +187,6 @@ fn check_updates_some() {
193187
expect_ok(config, &["rustup", "update", "stable"]);
194188
expect_ok(config, &["rustup", "update", "beta"]);
195189
expect_ok(config, &["rustup", "update", "nightly"]);
196-
expect_ok(config, &["rustup", "upgrade", "stable"]);
197-
expect_ok(config, &["rustup", "upgrade", "beta"]);
198-
expect_ok(config, &["rustup", "upgrade", "nightly"]);
199190
set_current_dist_date(config, "2015-01-02");
200191
expect_stdout_ok(
201192
config,

tests/cli-ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs;
22

33
#[test]
4-
fn ui_tests() {
4+
fn ui_doc_text_tests() {
55
let t = trycmd::TestCases::new();
66
let rustup_init = trycmd::cargo::cargo_bin("rustup-init");
77
let rustup = trycmd::cargo::cargo_bin("rustup");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
bin.name = "rustup"
2+
args = ["up","--help"]
3+
stdout = """
4+
...
5+
Update Rust toolchains and rustup
6+
7+
USAGE:
8+
rustup[EXE] update [FLAGS] [toolchain]...
9+
10+
FLAGS:
11+
--force Force an update, even if some components are missing
12+
--force-non-host Install toolchains that require an emulator. See https://github.com/rust-
13+
lang/rustup/wiki/Non-host-toolchains
14+
-h, --help Prints help information
15+
--no-self-update Don't perform self update when running the `rustup update` command
16+
17+
ARGS:
18+
<toolchain>... Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help
19+
toolchain`
20+
21+
DISCUSSION:
22+
With no toolchain specified, the `update` command updates each of
23+
the installed toolchains from the official release channels, then
24+
updates rustup itself.
25+
26+
If given a toolchain argument then `update` updates that
27+
toolchain, the same as `rustup toolchain install`.
28+
"""
29+
stderr = ""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
bin.name = "rustup"
2+
args = ["upgrade","--help"]
3+
stdout = """
4+
...
5+
Update Rust toolchains and rustup
6+
7+
USAGE:
8+
rustup[EXE] update [FLAGS] [toolchain]...
9+
10+
FLAGS:
11+
--force Force an update, even if some components are missing
12+
--force-non-host Install toolchains that require an emulator. See https://github.com/rust-
13+
lang/rustup/wiki/Non-host-toolchains
14+
-h, --help Prints help information
15+
--no-self-update Don't perform self update when running the `rustup update` command
16+
17+
ARGS:
18+
<toolchain>... Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help
19+
toolchain`
20+
21+
DISCUSSION:
22+
With no toolchain specified, the `update` command updates each of
23+
the installed toolchains from the official release channels, then
24+
updates rustup itself.
25+
26+
If given a toolchain argument then `update` updates that
27+
toolchain, the same as `rustup toolchain install`.
28+
"""
29+
stderr = ""

tests/mock/clitools.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::io;
1010
use std::path::{Path, PathBuf};
1111
use std::process::Command;
1212
use std::sync::Arc;
13+
use std::time::Instant;
1314

1415
use lazy_static::lazy_static;
1516
use url::Url;
@@ -602,11 +603,13 @@ where
602603
A: AsRef<OsStr>,
603604
{
604605
let inprocess = allow_inprocess(name, args.clone());
606+
let start = Instant::now();
605607
let out = if inprocess {
606608
run_inprocess(config, name, args, env)
607609
} else {
608610
run_subprocess(config, name, args, env)
609611
};
612+
let duration = Instant::now() - start;
610613
let output = SanitizedOutput {
611614
ok: matches!(out.status, Some(0)),
612615
stdout: String::from_utf8(out.stdout).unwrap(),
@@ -615,8 +618,9 @@ where
615618

616619
println!("inprocess: {inprocess}");
617620
println!("status: {:?}", out.status);
618-
println!("----- stdout\n{}", output.stdout);
619-
println!("----- stderr\n{}", output.stderr);
621+
println!("duration: {:.3}s", duration.as_secs_f32());
622+
println!("stdout:\n====\n{}\n====\n", output.stdout);
623+
println!("stderr:\n====\n{}\n====\n", output.stderr);
620624

621625
output
622626
}

0 commit comments

Comments
 (0)