Skip to content

Commit 6c15439

Browse files
epagerami3l
authored andcommitted
test: Add unknown arg init test
1 parent 7ce795c commit 6c15439

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

tests/suite/cli_rustup_init_ui.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ fn test_help(name: &str, args: &[&str]) {
2727
.stderr_eq("");
2828
}
2929

30+
#[track_caller]
31+
fn test_error(name: &str, args: &[&str]) {
32+
let home = Path::new(env!("CARGO_TARGET_TMPDIR")).join("home-ro");
33+
create_dir_all(&home).unwrap();
34+
35+
let rustup_init = snapbox::cmd::cargo_bin!("rustup-init");
36+
Command::new(rustup_init)
37+
.env("RUSTUP_TERM_COLOR", "always")
38+
// once installed rustup asserts the presence of ~/.rustup/settings.toml if
39+
// Config is instantiated.
40+
.env("HOME", &home)
41+
.args(args)
42+
.assert()
43+
.failure()
44+
.stdout_eq("")
45+
.stderr_eq(Data::read_from(
46+
Path::new(&format!("tests/suite/cli_rustup_ui/{name}.stderr.term.svg")),
47+
None,
48+
));
49+
}
50+
3051
#[track_caller]
3152
#[cfg(not(target_os = "windows"))] // On windows, we don't use rustup-init.sh
3253
fn test_sh_help(name: &str, args: &[&str]) {
@@ -57,6 +78,11 @@ fn rustup_init_help_flag() {
5778
test_help("rustup_init_help_flag", &["--help"]);
5879
}
5980

81+
#[test]
82+
fn rustup_init_unknown_arg() {
83+
test_error("rustup_init_unknown_arg", &["--random"]);
84+
}
85+
6086
#[test]
6187
#[cfg(not(target_os = "windows"))] // On windows, we don't use rustup-init.sh
6288
fn rustup_init_sh_help_flag() {
Lines changed: 37 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)