Merge pull request #3652 from epage/stdio

test(output): Ensure correct streams
This commit is contained in:
Ed Page 2022-04-22 11:06:05 -05:00 committed by GitHub
commit 3fa690e888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 165 additions and 0 deletions

14
src/bin/stdio-fixture.rs Normal file
View file

@ -0,0 +1,14 @@
fn main() {
let cmd = clap::Command::new("stdio-fixture")
.version("1.0")
.long_version("1.0 - a2132c")
.arg_required_else_help(true)
.subcommand(clap::Command::new("more"))
.arg(
clap::Arg::new("verbose")
.long("--verbose")
.help("log")
.long_help("more log"),
);
cmd.get_matches();
}

33
tests/ui.rs Normal file
View file

@ -0,0 +1,33 @@
#![cfg(not(tarpaulin))]
#[test]
fn ui_tests() {
let t = trycmd::TestCases::new();
let features = [
#[cfg(feature = "std")]
"std",
#[cfg(feature = "derive")]
"derive",
#[cfg(feature = "cargo")]
"cargo",
#[cfg(feature = "color")]
"color",
#[cfg(feature = "env")]
"env",
#[cfg(feature = "suggestions")]
"suggestions",
#[cfg(feature = "unicode")]
"unicode",
#[cfg(feature = "wrap_help")]
"wrap_help",
#[cfg(feature = "unstable-replace")]
"unstable-replace",
#[cfg(feature = "unstable-multicall")]
"unstable-multicall",
#[cfg(feature = "unstable-grouped")]
"unstable-grouped",
]
.join(" ");
t.register_bins(trycmd::cargo::compile_examples(["--features", &features]).unwrap());
t.case("tests/ui/*.toml");
}

View file

@ -0,0 +1,7 @@
bin.name = "stdio-fixture"
args = ["-V"]
status.code = 0
stdout = """
stdio-fixture 1.0
"""
stderr = ""

View file

@ -0,0 +1,19 @@
bin.name = "stdio-fixture"
args = []
status.code = 2
stdout = ""
stderr = """
stdio-fixture 1.0
USAGE:
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
OPTIONS:
-h, --help Print help information
-V, --version Print version information
--verbose log
SUBCOMMANDS:
help Print this message or the help of the given subcommand(s)
more
"""

View file

@ -0,0 +1,14 @@
bin.name = "stdio-fixture"
args = ["--unknown-argument"]
status.code = 2
stdout = ""
stderr = """
error: Found argument '--unknown-argument' which wasn't expected, or isn't valid in this context
\tIf you tried to supply `--unknown-argument` as a value rather than a flag, use `-- --unknown-argument`
USAGE:
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
For more information try --help
"""

View file

@ -0,0 +1,19 @@
bin.name = "stdio-fixture"
args = ["-h"]
status.code = 0
stdout = """
stdio-fixture 1.0
USAGE:
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
OPTIONS:
-h, --help Print help information
-V, --version Print version information
--verbose log
SUBCOMMANDS:
help Print this message or the help of the given subcommand(s)
more
"""
stderr = ""

View file

@ -0,0 +1,26 @@
bin.name = "stdio-fixture"
args = ["help"]
status.code = 0
stdout = """
stdio-fixture 1.0
USAGE:
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
OPTIONS:
-h, --help
Print help information
-V, --version
Print version information
--verbose
more log
SUBCOMMANDS:
help
Print this message or the help of the given subcommand(s)
more
"""
stderr = ""

View file

@ -0,0 +1,26 @@
bin.name = "stdio-fixture"
args = ["--help"]
status.code = 0
stdout = """
stdio-fixture 1.0
USAGE:
stdio-fixture[EXE] [OPTIONS] [SUBCOMMAND]
OPTIONS:
-h, --help
Print help information
-V, --version
Print version information
--verbose
more log
SUBCOMMANDS:
help
Print this message or the help of the given subcommand(s)
more
"""
stderr = ""

View file

@ -0,0 +1,7 @@
bin.name = "stdio-fixture"
args = ["--version"]
status.code = 0
stdout = """
stdio-fixture 1.0 - a2132c
"""
stderr = ""