More integration tests

This commit is contained in:
Casey Rodarmor 2016-10-28 15:59:50 -07:00
parent e011f91656
commit a8a5c342e7
5 changed files with 59 additions and 11 deletions

View File

@ -1,9 +1,12 @@
test-all: test test-integration
test:
cargo test --lib
cargo test --lib --test integration
test-integration: build
cargo test --test integration
test-quine:
cargo run -- quine clean

3
notes
View File

@ -3,11 +3,8 @@ notes
- integration testing
. --show should not display variable and expression values
. test --list
. test that status code of failing test is reported
. run app with command line options and test full output (stderr and stdout)
. exercise all features and all command line options
. test that first recipe runs by default
. test that a few error messages are correct
. test full output
. underline problem token in error messages

View File

@ -100,7 +100,7 @@ pub fn app() {
if justfile.count() == 0 {
warn!("Justfile contains no recipes");
} else {
warn!("{}", justfile.recipes().join(" "));
println!("{}", justfile.recipes().join(" "));
}
process::exit(0);
}
@ -125,7 +125,6 @@ pub fn app() {
if let Err(run_error) = justfile.run(&names) {
warn!("{}", run_error);
//process::exit(if let super::RunError::Code{code, ..} = run_error { code } else { -1 });
process::exit(-1);
process::exit(if let super::RunError::Code{code, ..} = run_error { code } else { -1 });
}
}

View File

@ -51,11 +51,11 @@ fn integration_test(
}
#[test]
fn simple() {
fn default() {
integration_test(
"simple",
"default",
&[],
"default:\n echo hello",
"default:\n echo hello\nother: \n echo bar",
0,
"hello\n",
"echo hello\n",
@ -102,3 +102,52 @@ c: b
"echo a\necho b\necho c\necho d\n",
);
}
#[test]
fn list() {
let text =
"b: a
a:
d: c
c: b";
integration_test(
"list",
&["--list"],
text,
0,
"a b c d\n",
"",
);
}
// #[test]
// fn show() {
// let text =
// r#"hello = "foo"
// recipe:
// echo {{hello}}"#;
// integration_test(
// "show",
// &["--show", "recipe"],
// text,
// 0,
// "foo\n",
// "",
// );
// }
#[test]
fn status() {
let text =
"
recipe:
@function f { return 100; }; f";
integration_test(
"status",
&[],
text,
100,
"",
"Recipe \"recipe\" failed with exit code 100\n",
);
}

View File

@ -672,7 +672,7 @@ impl<'a> Display for RunError<'a> {
try!(write!(f, "Running recipes with arguments is not yet supported"));
},
RunError::Code{recipe, code} => {
try!(write!(f, "Recipe \"{}\" failed with code {}", recipe, code));
try!(write!(f, "Recipe \"{}\" failed with exit code {}", recipe, code));
},
RunError::Signal{recipe, signal} => {
try!(write!(f, "Recipe \"{}\" wast terminated by signal {}", recipe, signal));