Skip to content

Commit 99f5fd4

Browse files
authored
Merge pull request #2423 from rbtcollins/unit-tests
Consolidate install smoke tests
2 parents 22dc71a + db93f5d commit 99f5fd4

File tree

1 file changed

+47
-67
lines changed

1 file changed

+47
-67
lines changed

tests/cli-self-upd.rs

+47-67
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,36 @@ version = "{}"
8383
}
8484

8585
#[test]
86+
/// This is the primary smoke test testing the full end to end behaviour of the
87+
/// installation code path: everything that is output, the proxy installation,
88+
/// status of the proxies.
8689
fn install_bins_to_cargo_home() {
8790
setup(&|config| {
88-
expect_ok(config, &["rustup-init", "-y"]);
91+
expect_ok_contains(
92+
config,
93+
&["rustup-init", "-y"],
94+
for_host!(
95+
r"
96+
stable-{0} installed - 1.1.0 (hash-stable-1.1.0)
97+
98+
"
99+
),
100+
for_host!(
101+
r"info: syncing channel updates for 'stable-{0}'
102+
info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0)
103+
info: downloading component 'cargo'
104+
info: downloading component 'rust-docs'
105+
info: downloading component 'rust-std'
106+
info: downloading component 'rustc'
107+
info: installing component 'cargo'
108+
info: Defaulting to 500.0 MiB unpack ram
109+
info: installing component 'rust-docs'
110+
info: installing component 'rust-std'
111+
info: installing component 'rustc'
112+
info: default toolchain set to 'stable-{0}'
113+
"
114+
),
115+
);
89116
let rustup = config.cargodir.join(&format!("bin/rustup{}", EXE_SUFFIX));
90117
let rustc = config.cargodir.join(&format!("bin/rustc{}", EXE_SUFFIX));
91118
let rustdoc = config.cargodir.join(&format!("bin/rustdoc{}", EXE_SUFFIX));
@@ -94,12 +121,25 @@ fn install_bins_to_cargo_home() {
94121
.cargodir
95122
.join(&format!("bin/rust-lldb{}", EXE_SUFFIX));
96123
let rust_gdb = config.cargodir.join(&format!("bin/rust-gdb{}", EXE_SUFFIX));
97-
assert!(rustup.exists());
98-
assert!(rustc.exists());
99-
assert!(rustdoc.exists());
100-
assert!(cargo.exists());
101-
assert!(rust_lldb.exists());
102-
assert!(rust_gdb.exists());
124+
#[cfg(windows)]
125+
fn check(path: &Path) {
126+
assert!(path.exists());
127+
}
128+
#[cfg(not(windows))]
129+
fn check(path: &Path) {
130+
fn is_exe(path: &Path) -> bool {
131+
use std::os::unix::fs::MetadataExt;
132+
let mode = path.metadata().unwrap().mode();
133+
mode & 0o777 == 0o755
134+
}
135+
assert!(is_exe(path));
136+
}
137+
check(&rustup);
138+
check(&rustc);
139+
check(&rustdoc);
140+
check(&cargo);
141+
check(&rust_lldb);
142+
check(&rust_gdb);
103143
});
104144
}
105145

@@ -113,35 +153,6 @@ fn install_twice() {
113153
});
114154
}
115155

116-
#[test]
117-
#[cfg(unix)]
118-
fn bins_are_executable() {
119-
setup(&|config| {
120-
expect_ok(config, &["rustup-init", "-y"]);
121-
let rustup = config.cargodir.join(&format!("bin/rustup{}", EXE_SUFFIX));
122-
let rustc = config.cargodir.join(&format!("bin/rustc{}", EXE_SUFFIX));
123-
let rustdoc = config.cargodir.join(&format!("bin/rustdoc{}", EXE_SUFFIX));
124-
let cargo = config.cargodir.join(&format!("bin/cargo{}", EXE_SUFFIX));
125-
let rust_lldb = config
126-
.cargodir
127-
.join(&format!("bin/rust-lldb{}", EXE_SUFFIX));
128-
let rust_gdb = config.cargodir.join(&format!("bin/rust-gdb{}", EXE_SUFFIX));
129-
assert!(is_exe(&rustup));
130-
assert!(is_exe(&rustc));
131-
assert!(is_exe(&rustdoc));
132-
assert!(is_exe(&cargo));
133-
assert!(is_exe(&rust_lldb));
134-
assert!(is_exe(&rust_gdb));
135-
});
136-
137-
fn is_exe(path: &Path) -> bool {
138-
use std::os::unix::fs::MetadataExt;
139-
let mode = path.metadata().unwrap().mode();
140-
141-
mode & 0o777 == 0o755
142-
}
143-
}
144-
145156
#[test]
146157
fn install_creates_cargo_home() {
147158
setup(&|config| {
@@ -820,37 +831,6 @@ fn as_rustup_setup() {
820831
});
821832
}
822833

823-
#[test]
824-
fn first_install_exact() {
825-
setup(&|config| {
826-
expect_ok_contains(
827-
config,
828-
&["rustup-init", "-y"],
829-
for_host!(
830-
r"
831-
stable-{0} installed - 1.1.0 (hash-stable-1.1.0)
832-
833-
"
834-
),
835-
for_host!(
836-
r"info: syncing channel updates for 'stable-{0}'
837-
info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0)
838-
info: downloading component 'cargo'
839-
info: downloading component 'rust-docs'
840-
info: downloading component 'rust-std'
841-
info: downloading component 'rustc'
842-
info: installing component 'cargo'
843-
info: Defaulting to 500.0 MiB unpack ram
844-
info: installing component 'rust-docs'
845-
info: installing component 'rust-std'
846-
info: installing component 'rustc'
847-
info: default toolchain set to 'stable-{0}'
848-
"
849-
),
850-
);
851-
});
852-
}
853-
854834
#[test]
855835
fn reinstall_exact() {
856836
setup(&|config| {

0 commit comments

Comments
 (0)