From a8a5c342e7d68a822f2f2db8281c9ec4e9db62a7 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 28 Oct 2016 15:59:50 -0700 Subject: [PATCH] More integration tests --- justfile | 5 ++++- notes | 3 --- src/app.rs | 5 ++--- src/integration.rs | 55 +++++++++++++++++++++++++++++++++++++++++++--- src/lib.rs | 2 +- 5 files changed, 59 insertions(+), 11 deletions(-) diff --git a/justfile b/justfile index 023f69f..4a9e9e0 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/notes b/notes index 83570b2..fa48b98 100644 --- a/notes +++ b/notes @@ -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 diff --git a/src/app.rs b/src/app.rs index 79b4321..241aa28 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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 }); } } diff --git a/src/integration.rs b/src/integration.rs index 5694134..1376358 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -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", + ); +} diff --git a/src/lib.rs b/src/lib.rs index 6d63dfe..ab11826 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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));