Skip to content

Commit

Permalink
Update rustup mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-rustin committed Mar 3, 2023
1 parent 71a0e70 commit ab6e728
Show file tree
Hide file tree
Showing 44 changed files with 261 additions and 256 deletions.
25 changes: 7 additions & 18 deletions src/cli/rustup_mode.rs
Expand Up @@ -71,11 +71,11 @@ pub fn main() -> Result<utils::ExitCode> {
let matches = match cli().try_get_matches_from(process().args_os()) {
Ok(matches) => Ok(matches),
Err(err) if err.kind() == DisplayHelp => {
writeln!(process().stdout().lock(), "{}", err)?;
writeln!(process().stdout().lock(), "{err}")?;
return Ok(utils::ExitCode(0));
}
Err(err) if err.kind() == DisplayVersion => {
writeln!(process().stdout().lock(), "{}", err)?;
writeln!(process().stdout().lock(), "{err}")?;
info!("This is the version for the rustup toolchain manager, not the rustc compiler.");

fn rustc_version() -> std::result::Result<String, Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn main() -> Result<utils::ExitCode> {
]
.contains(&err.kind())
{
writeln!(process().stdout().lock(), "{}", err)?;
writeln!(process().stdout().lock(), "{err}")?;
return Ok(utils::ExitCode(1));
}
Err(err)
Expand Down Expand Up @@ -207,16 +207,6 @@ pub(crate) fn cli() -> Command<'static> {
.arg(
verbose_arg("Enable verbose output"),
)
.help_template(
"\
{name} {version}
{about}
USAGE:
{usage}
{all-args}",
)
.arg(
Arg::new("quiet")
.conflicts_with("verbose")
Expand Down Expand Up @@ -351,7 +341,6 @@ USAGE:
Arg::new("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(false)
.takes_value(true),
),
)
.subcommand(
Expand Down Expand Up @@ -392,7 +381,7 @@ USAGE:
.takes_value(true)
.multiple_values(true)
.use_value_delimiter(true)
.action(ArgAction::Append),
.action(ArgAction::Append),
)
.arg(
Arg::new("targets")
Expand All @@ -401,8 +390,8 @@ USAGE:
.short('t')
.takes_value(true)
.multiple_values(true)
.multiple_occurrences(true)
.use_value_delimiter(true),
.use_value_delimiter(true)
.action(ArgAction::Append),
)
.arg(
Arg::new("no-self-update")
Expand Down Expand Up @@ -1520,7 +1509,7 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
info!("override toolchain for '{}' removed", path);
} else {
info!("no override toolchain for '{}'", path);
if !m.get_one::<String>("path").is_some() && !m.get_flag("nonexistent") {
if m.get_one::<String>("path").is_none() && !m.get_flag("nonexistent") {
info!(
"you may use `--path <path>` option to remove override toolchain \
for a specific path"
Expand Down
Expand Up @@ -7,7 +7,8 @@ Check for updates to Rust toolchains and rustup
USAGE:
rustup[EXE] check
FLAGS:
-h, --help Prints help information
OPTIONS:
-h, --help Print help information
"""
stderr = ""
Expand Up @@ -7,12 +7,12 @@ Generate tab-completion scripts for your shell
USAGE:
rustup[EXE] completions [ARGS]
FLAGS:
-h, --help Prints help information
ARGS:
<shell> [possible values: zsh, bash, fish, powershell, elvish]
<command> [possible values: rustup, cargo]
<shell> [possible values: bash, elvish, fish, powershell, zsh]
<command> [possible values: rustup, cargo]
OPTIONS:
-h, --help Print help information
DISCUSSION:
Enable tab completion for Bash, Fish, Zsh, or PowerShell
Expand Down Expand Up @@ -134,5 +134,6 @@ ${env:USERPROFILE}/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1
ZSH:
$ rustup completions zsh cargo > ~/.zfunc/_cargo
"""
stderr = ""
Expand Up @@ -7,15 +7,14 @@ Add a component to a Rust toolchain
USAGE:
rustup[EXE] component add [OPTIONS] <component>...
FLAGS:
-h, --help Prints help information
ARGS:
<component>...
OPTIONS:
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
information see `rustup help toolchain`
--target <target>
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
`rustup help toolchain`
-h, --help Print help information
ARGS:
<component>...
"""
stderr = ""
Expand Up @@ -5,14 +5,13 @@ stdout = """
List installed and available components
USAGE:
rustup[EXE] component list [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
--installed List only installed components
rustup[EXE] component list [OPTIONS]
OPTIONS:
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
`rustup help toolchain`
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
information see `rustup help toolchain`
--installed List only installed components
-h, --help Print help information
"""
stderr = ""
Expand Up @@ -7,15 +7,14 @@ Remove a component from a Rust toolchain
USAGE:
rustup[EXE] component remove [OPTIONS] <component>...
FLAGS:
-h, --help Prints help information
ARGS:
<component>...
OPTIONS:
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
information see `rustup help toolchain`
--target <target>
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
`rustup help toolchain`
-h, --help Print help information
ARGS:
<component>...
"""
stderr = ""
Expand Up @@ -7,15 +7,16 @@ Set the default toolchain
USAGE:
rustup[EXE] default [toolchain]
FLAGS:
-h, --help Prints help information
ARGS:
<toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help
toolchain`
<toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information
see `rustup help toolchain`
OPTIONS:
-h, --help Print help information
DISCUSSION:
Sets the default toolchain to the one specified. If the toolchain
is not already installed then it is installed first.
"""
stderr = ""
53 changes: 27 additions & 26 deletions tests/suite/cli-ui/rustup/rustup_doc_cmd_help_flag_stdout.toml
Expand Up @@ -5,41 +5,42 @@ stdout = """
Open the documentation for the current toolchain
USAGE:
rustup[EXE] doc [FLAGS] [OPTIONS] [topic]
rustup[EXE] doc [OPTIONS] [topic]
FLAGS:
--alloc The Rust core allocation and collections library
--book The Rust Programming Language book
--cargo The Cargo Book
--core The Rust Core Library
--edition-guide The Rust Edition Guide
--embedded-book The Embedded Rust Book
-h, --help Prints help information
--nomicon The Dark Arts of Advanced and Unsafe Rust Programming
--path Only print the path to the documentation
--proc_macro A support library for macro authors when defining new macros
--reference The Rust Reference
--rust-by-example A collection of runnable examples that illustrate various Rust concepts and standard
libraries
--rustc The compiler for the Rust programming language
--rustdoc Documentation generator for Rust projects
--std Standard library API documentation
--test Support code for rustc's built in unit-test and micro-benchmarking framework
--unstable-book The Unstable Book
ARGS:
<topic> Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!',
'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum',
'std::io::error::Result' etc...
OPTIONS:
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
`rustup help toolchain`
ARGS:
<topic> Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs',
'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...
--path Only print the path to the documentation
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
information see `rustup help toolchain`
--alloc The Rust core allocation and collections library
--book The Rust Programming Language book
--cargo The Cargo Book
--core The Rust Core Library
--edition-guide The Rust Edition Guide
--nomicon The Dark Arts of Advanced and Unsafe Rust Programming
--proc_macro A support library for macro authors when defining new macros
--reference The Rust Reference
--rust-by-example A collection of runnable examples that illustrate various Rust
concepts and standard libraries
--rustc The compiler for the Rust programming language
--rustdoc Documentation generator for Rust projects
--std Standard library API documentation
--test Support code for rustc's built in unit-test and
micro-benchmarking framework
--unstable-book The Unstable Book
--embedded-book The Embedded Rust Book
-h, --help Print help information
DISCUSSION:
Opens the documentation for the currently active toolchain with
the default browser.
By default, it opens the documentation index. Use the various
flags to open specific pieces of documentation.
"""
stderr = ""
19 changes: 10 additions & 9 deletions tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml
Expand Up @@ -6,17 +6,17 @@ rustup [..]
The Rust toolchain installer
USAGE:
rustup[EXE] [FLAGS] [+toolchain] <SUBCOMMAND>
FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Prints help information
-V, --version Prints version information
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
OPTIONS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
show Show the active and installed toolchains or profiles
update Update Rust toolchains and rustup
Expand All @@ -29,11 +29,11 @@ SUBCOMMANDS:
run Run a command with an environment configured for a given toolchain
which Display which binary will be run for a given command
doc Open the documentation for the current toolchain
...
man View the man page for a given command
self Modify the rustup installation
set Alter rustup settings
completions Generate tab-completion scripts for your shell
help Prints this message or the help of the given subcommand(s)
help Print this message or the help of the given subcommand(s)
DISCUSSION:
Rustup installs The Rust Programming Language from the official
Expand All @@ -44,5 +44,6 @@ DISCUSSION:
If you are new to Rust consider running `rustup doc --book` to
learn Rust.
"""
stderr = ""
19 changes: 10 additions & 9 deletions tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml
Expand Up @@ -6,17 +6,17 @@ rustup [..]
The Rust toolchain installer
USAGE:
rustup[EXE] [FLAGS] [+toolchain] <SUBCOMMAND>
FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Prints help information
-V, --version Prints version information
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
OPTIONS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
show Show the active and installed toolchains or profiles
update Update Rust toolchains and rustup
Expand All @@ -29,11 +29,11 @@ SUBCOMMANDS:
run Run a command with an environment configured for a given toolchain
which Display which binary will be run for a given command
doc Open the documentation for the current toolchain
...
man View the man page for a given command
self Modify the rustup installation
set Alter rustup settings
completions Generate tab-completion scripts for your shell
help Prints this message or the help of the given subcommand(s)
help Print this message or the help of the given subcommand(s)
DISCUSSION:
Rustup installs The Rust Programming Language from the official
Expand All @@ -44,5 +44,6 @@ DISCUSSION:
If you are new to Rust consider running `rustup doc --book` to
learn Rust.
"""
stderr = ""
11 changes: 5 additions & 6 deletions tests/suite/cli-ui/rustup/rustup_man_cmd_help_flag_stdout.toml
Expand Up @@ -7,14 +7,13 @@ View the man page for a given command
USAGE:
rustup[EXE] man [OPTIONS] <command>
FLAGS:
-h, --help Prints help information
ARGS:
<command>
OPTIONS:
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
`rustup help toolchain`
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
information see `rustup help toolchain`
-h, --help Print help information
ARGS:
<command>
"""
stderr = ""
Expand Up @@ -7,14 +7,13 @@ Set the override toolchain for a directory
USAGE:
rustup[EXE] override set [OPTIONS] <toolchain>
FLAGS:
-h, --help Prints help information
ARGS:
<toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information
see `rustup help toolchain`
OPTIONS:
--path <path> Path to the directory
-h, --help Print help information
ARGS:
<toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help
toolchain`
"""
stderr = ""

0 comments on commit ab6e728

Please sign in to comment.