-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
- Loading branch information
1 parent
49023e1
commit cbadeef
Showing
48 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,58 @@ | ||
use std::fs; | ||
use std::{fs, path::PathBuf}; | ||
|
||
#[test] | ||
fn ui_doc_text_tests() { | ||
fn rustup_ui_doc_text_tests() { | ||
let t = trycmd::TestCases::new(); | ||
let rustup_init = trycmd::cargo::cargo_bin("rustup-init"); | ||
let rustup = trycmd::cargo::cargo_bin("rustup"); | ||
t.register_bin("rustup-init", &rustup_init); | ||
// Copy rustup-init to rustup so that the tests can run it. | ||
fs::copy(&rustup_init, &rustup).unwrap(); | ||
t.register_bin("rustup", &rustup); | ||
t.case("tests/cli-ui/*.toml"); | ||
t.case("tests/cli-ui/rustup/*.toml"); | ||
#[cfg(target_os = "windows")] | ||
{ | ||
// On windows, we don't have man command, so skip the tests. | ||
t.skip("tests/cli-ui/rustup_man_cmd_help_flag_stdout.toml"); | ||
// On windows, we don't have man command, so skip the test. | ||
t.skip("tests/cli-ui/rustup/rustup_man_cmd_help_flag_stdout.toml"); | ||
} | ||
} | ||
|
||
#[test] | ||
fn rustup_init_ui_doc_text_tests() { | ||
let t = trycmd::TestCases::new(); | ||
let rustup_init = trycmd::cargo::cargo_bin("rustup-init"); | ||
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
t.register_bin("rustup-init", &rustup_init); | ||
t.register_bin("rustup-init.sh", &project_root.join("rustup-init.sh")); | ||
t.case("tests/cli-ui/rustup-init/*.toml"); | ||
#[cfg(target_os = "windows")] | ||
{ | ||
// On non-windows, we don't use rustup-init.sh, so skip the test. | ||
t.skip("tests/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml"); | ||
} | ||
|
||
// On non-windows, we don't use rustup-init.sh, so skip the test. | ||
#[cfg(not(target_os = "windows"))] | ||
{ | ||
let rustup_init_help_toml = | ||
project_root.join("tests/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml"); | ||
let rustup_init_sh_help_toml = | ||
project_root.join("tests/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml"); | ||
|
||
#[derive(Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)] | ||
struct Stdout { | ||
#[serde(default)] | ||
pub(crate) stdout: Option<String>, | ||
} | ||
let rustup_init_help_std_out: Stdout = | ||
toml::from_str(fs::read_to_string(rustup_init_help_toml).unwrap().as_str()).unwrap(); | ||
let rustup_init_sh_help_std_out: Stdout = toml::from_str( | ||
fs::read_to_string(rustup_init_sh_help_toml) | ||
.unwrap() | ||
.as_str(), | ||
) | ||
.unwrap(); | ||
|
||
// Make sure that the help output of rustup-init and rustup-init.sh are the same. | ||
assert!(rustup_init_help_std_out == rustup_init_sh_help_std_out) | ||
} | ||
} |
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
tests/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
bin.name = "rustup-init.sh" | ||
args = ["--help"] | ||
status.code = 0 | ||
stdout = """ | ||
rustup-init [..] | ||
The installer for rustup | ||
USAGE: | ||
rustup-init[EXE] [FLAGS] [OPTIONS] | ||
FLAGS: | ||
-v, --verbose Enable verbose output | ||
-q, --quiet Disable progress output | ||
-y Disable confirmation prompt. | ||
--no-update-default-toolchain Don't update any existing default toolchain after install | ||
--no-modify-path Don't configure the PATH environment variable | ||
-h, --help Prints help information | ||
-V, --version Prints version information | ||
OPTIONS: | ||
--default-host <default-host> Choose a default host triple | ||
--default-toolchain <default-toolchain> Choose a default toolchain to install | ||
--profile <profile> [default: default] [possible values: minimal, default, complete] | ||
-c, --component <components>... Component name to also install | ||
-t, --target <targets>... Target name to also install | ||
""" | ||
stderr = "" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.