0.5.3 |
|
---|---|
0.5.2 |
|
0.4.1 |
|
0.3.7 |
|
0.1.2 |
|
#41 in #longer
31 downloads per month
32KB
641 lines
This project is no longer maintained.
lib.rs
:
UI testing for arbitrary Command
s.
Examples
All the .stdout
files listed below can be found in the tests/ui
directory in this crate's repository.
Test that cargo build -q
runs successfully and has empty output without normalization
Command::cargo("build").arg("-q").run_pass(OutputStr::empty(), normalize::noop());
Test that cargo miri test -q
runs successfully and has expected stdout and empty stderr without normalization
use tryrun::prelude::*;
Command::cargo_miri("test")
.env_remove("LD_LIBRARY_PATH")
.env_remove("DYLD_FALLBACK_LIBRARY_PATH")
.args(&["-q", "--lib", "--target-dir=target/miri"])
.run_pass(OutputStr::stdout("tests/ui/cargo_miri_test.stdout"), normalize::noop());
### Test that `rustc -V` runs successfully and has expected stdout after normalization and empty stderr
use tryrun::prelude::*;
Command::rustc().arg("-V").run_pass( OutputStr::stdout("tests/ui/rustc_version.stdout"), normalize::stdout(|output| { output.truncate("rustc 1.".len()); output.push(b'\n'); output }), );
### Test that `rustdoc -V` runs successfully and has expected stdout after normalization and empty stderr
use tryrun::prelude::*;
Command::rustdoc().arg("-V").run_pass( OutputStr::stdout("tests/ui/rustdoc_version.stdout"), normalize::stdout(|output| { output.truncate("rustdoc 1.".len()); output.push(b'\n'); output }), );
### Test that `clippy-driver -V` runs successfully and has expected stdout after normalization and empty stderr
use tryrun::prelude::*;
Command::clippy().arg("-V").run_pass( OutputStr::stdout("tests/ui/clippy_version.stdout"), normalize::stdout(|output| { output.truncate("clippy".len()); output.push(b'\n'); output }), );
### Test that `false` runs unsucessfully and has empty output without normalization
use tryrun::prelude::*;
Command::new("false").run_fail(OutputStr::empty(), normalize::noop());
### Test that `false garbage` also runs unsucessfully and has empty output without normalization
use tryrun::prelude::*;
Command::new("false").arg("garbage").run_fail(OutputStr::empty(), normalize::noop());
### Blessing
This will update all used stdout and stderr files:
```shell
TRYRUN=bless cargo test
You can see some of the unit tests of this
src/lib.rs
for more examples.
Also see this crate's own UI tests
for more advanced examples.
Dependencies
To display a colourful diff, the git
command needs to be installed,
otherwise no helpful output will be shown for test failures.