Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ addons:
- libdw-dev
after_success:
- travis-cargo --only stable doc-upload
- rm tests/skeptic.rs # "skip" skeptic doctests for coverage
- travis-cargo coveralls --no-sudo
notifications:
email:
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
readme = "README.md"
documentation = "http://killercup.github.io/assert_cli/"
description = "Test CLI Applications."
build = "build.rs"

[features]
default = []
Expand All @@ -17,3 +18,9 @@ dev = ["clippy"]
ansi_term = "0.6.3"
difference = "0.4.0"
clippy = {version = "0.0.23", optional = true}

[build-dependencies]
skeptic = "0.5"

[dev-dependencies]
skeptic = "0.5"
28 changes: 19 additions & 9 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ Here's a trivial example:

```rust
extern crate assert_cli;
assert_cli::assert_cli_output("echo", &["42"], "42").unwrap();
fn main() {
assert_cli::assert_cli_output("echo", &["42"], "42").unwrap();
}
```

Or if you'd rather use the macro:

```rust,ignore
#[macro_use] extern crate assert_cli;
assert_cli!("echo", &["42"] => Success, "42").unwrap();
assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
fn main() {
assert_cli!("echo", &["42"] => Success, "42").unwrap();
assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
}
```

And here is one that will fail:

```rust,should_panic
extern crate assert_cli;
assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
fn main() {
assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
}
```

this will show a nice, colorful diff in your terminal, like this:
Expand All @@ -53,18 +59,22 @@ If you'd prefer to not check the output:

```rust
#[macro_use] extern crate assert_cli;
assert_cli::assert_cli("echo", &["42"]).unwrap();
assert_cli!("echo", &["42"] => Success).unwrap();
fn main() {
assert_cli::assert_cli("echo", &["42"]).unwrap();
assert_cli!("echo", &["42"] => Success).unwrap();
}
```

All exported functions and the macro return a `Result` containing the
`Output` of the process, allowing you to do further custom assertions:

```rust
#[macro_use] extern crate assert_cli;
let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
let stdout = std::str::from_utf8(&output.stdout).unwrap();
assert!(stdout.contains("42"));
fn main() {
let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
let stdout = std::str::from_utf8(&output.stdout).unwrap();
assert!(stdout.contains("42"));
}
```

## License
Expand Down
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extern crate skeptic;

fn main() {
skeptic::generate_doc_tests(&["README.md"]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to know how I know you use OS X? Case-insensitive file system! The filename is Readme.md. You can actually just rename the file if you want to, several other projects I have use upper-case README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, good catch. I didn't pay attention to that!

}
1 change: 1 addition & 0 deletions tests/skeptic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));