Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit f258611

Browse files
authored
Merge pull request #12 from johannhof/skeptic
Add skeptic support
2 parents 992fbfe + 3cb4331 commit f258611

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ addons:
2525
- libdw-dev
2626
after_success:
2727
- travis-cargo --only stable doc-upload
28+
- rm tests/skeptic.rs # "skip" skeptic doctests for coverage
2829
- travis-cargo coveralls --no-sudo
2930
notifications:
3031
email:

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
88
readme = "README.md"
99
documentation = "http://killercup.github.io/assert_cli/"
1010
description = "Test CLI Applications."
11+
build = "build.rs"
1112

1213
[features]
1314
default = []
@@ -17,3 +18,9 @@ dev = ["clippy"]
1718
ansi_term = "0.6.3"
1819
difference = "0.4.0"
1920
clippy = {version = "0.0.23", optional = true}
21+
22+
[build-dependencies]
23+
skeptic = "0.5"
24+
25+
[dev-dependencies]
26+
skeptic = "0.5"

Readme.md renamed to README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,28 @@ Here's a trivial example:
2424

2525
```rust
2626
extern crate assert_cli;
27-
assert_cli::assert_cli_output("echo", &["42"], "42").unwrap();
27+
fn main() {
28+
assert_cli::assert_cli_output("echo", &["42"], "42").unwrap();
29+
}
2830
```
2931

3032
Or if you'd rather use the macro:
3133

3234
```rust,ignore
3335
#[macro_use] extern crate assert_cli;
34-
assert_cli!("echo", &["42"] => Success, "42").unwrap();
35-
assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
36+
fn main() {
37+
assert_cli!("echo", &["42"] => Success, "42").unwrap();
38+
assert_cli!("black-box", &["--special"] => Error 42, "error no 42\n").unwrap()
39+
}
3640
```
3741

3842
And here is one that will fail:
3943

4044
```rust,should_panic
4145
extern crate assert_cli;
42-
assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
46+
fn main() {
47+
assert_cli::assert_cli_output("echo", &["42"], "1337").unwrap();
48+
}
4349
```
4450

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

5460
```rust
5561
#[macro_use] extern crate assert_cli;
56-
assert_cli::assert_cli("echo", &["42"]).unwrap();
57-
assert_cli!("echo", &["42"] => Success).unwrap();
62+
fn main() {
63+
assert_cli::assert_cli("echo", &["42"]).unwrap();
64+
assert_cli!("echo", &["42"] => Success).unwrap();
65+
}
5866
```
5967

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

6371
```rust
6472
#[macro_use] extern crate assert_cli;
65-
let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
66-
let stdout = std::str::from_utf8(&output.stdout).unwrap();
67-
assert!(stdout.contains("42"));
73+
fn main() {
74+
let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
75+
let stdout = std::str::from_utf8(&output.stdout).unwrap();
76+
assert!(stdout.contains("42"));
77+
}
6878
```
6979

7080
## License

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extern crate skeptic;
2+
3+
fn main() {
4+
skeptic::generate_doc_tests(&["README.md"]);
5+
}

tests/skeptic.rs

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

0 commit comments

Comments
 (0)