From 633f0ccaa6da83e13b9dbd87b1cdd9f371191bcc Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 6 Oct 2019 00:32:16 -0700 Subject: [PATCH] Allow integration test cases to omit common values (#480) --- tests/integration.rs | 500 +++++++++---------------------------------- 1 file changed, 102 insertions(+), 398 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 19c38eb..9352dd8 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -11,9 +11,110 @@ use std::{ use executable_path::executable_path; use libc::{EXIT_FAILURE, EXIT_SUCCESS}; use pretty_assertions::assert_eq; - use tempdir::tempdir; +/// Instantiate an integration test. +macro_rules! integration_test { + ( + name: $name:ident, + justfile: $justfile:tt, + $(args: ($($arg:tt)*),)? + $(stdin: $stdin:expr,)? + $(stdout: $stdout:expr,)? + $(stderr: $stderr:expr,)? + $(status: $status:expr,)? + ) => { + #[test] + fn $name() { + Test { + justfile: $justfile, + $(args: &[$($arg)*],)? + $(stdin: $stdin,)? + $(stdout: $stdout,)? + $(stderr: $stderr,)? + $(status: $status,)? + ..Test::default() + }.run(); + } + } +} + +struct Test<'a> { + justfile: &'a str, + args: &'a [&'a str], + stdin: &'a str, + stdout: &'a str, + stderr: &'a str, + status: i32, +} + +impl<'a> Default for Test<'a> { + fn default() -> Test<'a> { + Test { + justfile: "", + stdin: "", + args: &[], + stdout: "", + stderr: "", + status: EXIT_SUCCESS, + } + } +} + +impl<'a> Test<'a> { + fn run(self) { + let tmp = tempdir(); + + let mut justfile_path = tmp.path().to_path_buf(); + justfile_path.push("justfile"); + fs::write(justfile_path, self.justfile).unwrap(); + + let mut dotenv_path = tmp.path().to_path_buf(); + dotenv_path.push(".env"); + fs::write(dotenv_path, "DOTENV_KEY=dotenv-value").unwrap(); + + let mut child = Command::new(&executable_path("just")) + .current_dir(tmp.path()) + .args(&["--shell", "bash"]) + .args(self.args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("just invocation failed"); + + { + let mut stdin_handle = child.stdin.take().expect("failed to unwrap stdin handle"); + + stdin_handle + .write_all(self.stdin.as_bytes()) + .expect("failed to write stdin to just process"); + } + + let output = child + .wait_with_output() + .expect("failed to wait for just process"); + + let have = Output { + status: output.status.code().unwrap(), + stdout: str::from_utf8(&output.stdout).unwrap(), + stderr: str::from_utf8(&output.stderr).unwrap(), + }; + + let want = Output { + status: self.status, + stdout: self.stdout, + stderr: self.stderr, + }; + + assert_eq!(have, want, "bad output"); + + if self.status == EXIT_SUCCESS { + test_round_trip(tmp.path()); + } + } +} + #[derive(PartialEq, Debug)] struct Output<'a> { stdout: &'a str, @@ -21,89 +122,6 @@ struct Output<'a> { status: i32, } -/// Instantiate integration tests for a given test case using -/// sh, dash, and bash. -/// -/// Although `sh` is likely to be dash or bash, we include it -/// in case it's a different version or a different shell entirely. -/// -/// For example, on FreeBSD, `sh` is ash. -macro_rules! integration_test { - ( - name: $name:ident, - justfile: $text:tt, - args: ($($arg:tt)*), - stdin: $stdin:expr, - stdout: $stdout:expr, - stderr: $stderr:expr, - status: $status:expr, - ) => { - #[test] - fn $name() { - integration_test($text, &[$($arg)*], $stdin, $stdout, $stderr, $status); - } - } -} - -fn integration_test( - justfile: &str, - args: &[&str], - stdin: &str, - expected_stdout: &str, - expected_stderr: &str, - expected_status: i32, -) { - let tmp = tempdir(); - - let mut justfile_path = tmp.path().to_path_buf(); - justfile_path.push("justfile"); - fs::write(justfile_path, justfile).unwrap(); - - let mut dotenv_path = tmp.path().to_path_buf(); - dotenv_path.push(".env"); - fs::write(dotenv_path, "DOTENV_KEY=dotenv-value").unwrap(); - - let mut child = Command::new(&executable_path("just")) - .current_dir(tmp.path()) - .args(&["--shell", "bash"]) - .args(args) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .expect("just invocation failed"); - - { - let mut stdin_handle = child.stdin.take().expect("failed to unwrap stdin handle"); - - stdin_handle - .write_all(stdin.as_bytes()) - .expect("failed to write stdin to just process"); - } - - let output = child - .wait_with_output() - .expect("failed to wait for just process"); - - let have = Output { - status: output.status.code().unwrap(), - stdout: str::from_utf8(&output.stdout).unwrap(), - stderr: str::from_utf8(&output.stderr).unwrap(), - }; - - let want = Output { - status: expected_status, - stdout: expected_stdout, - stderr: expected_stderr, - }; - - assert_eq!(have, want, "bad output"); - - if expected_status == EXIT_SUCCESS { - test_round_trip(tmp.path()); - } -} - fn test_round_trip(tmpdir: &Path) { println!("Reparsing..."); @@ -144,89 +162,69 @@ integration_test! { name: alias_listing, justfile: "foo:\n echo foo\nalias f := foo", args: ("--list"), - stdin: "", stdout: "Available recipes: foo f # alias for `foo` ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: alias_listing_multiple_aliases, justfile: "foo:\n echo foo\nalias f := foo\nalias fo := foo", args: ("--list"), - stdin: "", stdout: "Available recipes: foo f # alias for `foo` fo # alias for `foo` ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: alias_listing_parameters, justfile: "foo PARAM='foo':\n echo {{PARAM}}\nalias f := foo", args: ("--list"), - stdin: "", stdout: "Available recipes: foo PARAM='foo' f PARAM='foo' # alias for `foo` ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: alias_listing_private, justfile: "foo PARAM='foo':\n echo {{PARAM}}\nalias _f := foo", args: ("--list"), - stdin: "", stdout: "Available recipes: foo PARAM='foo' ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: alias, justfile: "foo:\n echo foo\nalias f := foo", args: ("f"), - stdin: "", stdout: "foo\n", stderr: "echo foo\n", - status: EXIT_SUCCESS, } integration_test! { name: alias_with_parameters, justfile: "foo value='foo':\n echo {{value}}\nalias f := foo", args: ("f", "bar"), - stdin: "", stdout: "bar\n", stderr: "echo bar\n", - status: EXIT_SUCCESS, } integration_test! { name: alias_with_dependencies, justfile: "foo:\n echo foo\nbar: foo\nalias b := bar", args: ("b"), - stdin: "", stdout: "foo\n", stderr: "echo foo\n", - status: EXIT_SUCCESS, } integration_test! { name: duplicate_alias, justfile: "alias foo := bar\nalias foo := baz\n", - args: (), - stdin: "", stdout: "" , stderr: "error: Alias `foo` first defined on line `1` is redefined on line `2` | @@ -239,8 +237,6 @@ integration_test! { integration_test! { name: unknown_alias_target, justfile: "alias foo := bar\n", - args: (), - stdin: "", stdout: "", stderr: "error: Alias `foo` has an unknown target `bar` | @@ -253,8 +249,6 @@ integration_test! { integration_test! { name: alias_shadows_recipe, justfile: "bar:\n echo bar\nalias foo := bar\nfoo:\n echo foo", - args: (), - stdin: "", stdout: "", stderr: "error: Alias `foo` defined on `3` shadows recipe defined on `4` | @@ -268,19 +262,15 @@ integration_test! { name: alias_show, justfile: "foo:\n bar\nalias f := foo", args: ("--show", "f"), - stdin: "", stdout: "alias f := foo\nfoo: bar ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: alias_show_missing_target, justfile: "alias f := foo", args: ("--show", "f"), - stdin: "", stdout: "", stderr: "error: Alias `f` has an unknown target `foo` | @@ -293,31 +283,22 @@ integration_test! { integration_test! { name: default, justfile: "default:\n echo hello\nother: \n echo bar", - args: (), - stdin: "", stdout: "hello\n", stderr: "echo hello\n", - status: EXIT_SUCCESS, } integration_test! { name: quiet, justfile: "default:\n @echo hello", - args: (), - stdin: "", stdout: "hello\n", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: verbose, justfile: "default:\n @echo hello", args: ("--verbose"), - stdin: "", stdout: "hello\n", stderr: "===> Running recipe `default`...\necho hello\n", - status: EXIT_SUCCESS, } integration_test! { @@ -340,10 +321,8 @@ c: b echo c @mv b c", args: ("a", "d"), - stdin: "", stdout: "a\nb\nc\nd\n", stderr: "echo a\necho b\necho c\necho d\n", - status: EXIT_SUCCESS, } integration_test! { @@ -356,10 +335,7 @@ _z: _y _y: ", args: ("--summary"), - stdin: "", stdout: "a b c d\n", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -373,10 +349,7 @@ d: c: @echo c", args: ("d", "c"), - stdin: "", stdout: "d\nc\n", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -390,10 +363,8 @@ d: c: echo c", args: ("d", "c"), - stdin: "", stdout: "d\nc\n", stderr: "echo d\necho c\n", - status: EXIT_SUCCESS, } integration_test! { @@ -403,12 +374,9 @@ bar := hello + hello recipe: echo {{hello + "bar" + bar}}"#, args: ("--show", "recipe"), - stdin: "", stdout: r#"recipe: echo {{hello + "bar" + bar}} "#, - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -420,7 +388,6 @@ hello: recipe: @exit 100", args: ("recipe"), - stdin: "", stdout: "", stderr: "error: Recipe `recipe` failed on line 6 with exit code 100\n", status: 100, @@ -429,8 +396,6 @@ recipe: integration_test! { name: unknown_dependency, justfile: "bar:\nhello:\nfoo: bar baaaaaaaz hello", - args: (), - stdin: "", stdout: "", stderr: "error: Recipe `foo` has unknown dependency `baaaaaaaz` | @@ -443,28 +408,20 @@ integration_test! { integration_test! { name: backtick_success, justfile: "a := `printf Hello,`\nbar:\n printf '{{a + `printf ' world.'`}}'", - args: (), - stdin: "", stdout: "Hello, world.", stderr: "printf 'Hello, world.'\n", - status: EXIT_SUCCESS, } integration_test! { name: backtick_trimming, justfile: "a := `echo Hello,`\nbar:\n echo '{{a + `echo ' world.'`}}'", - args: (), - stdin: "", stdout: "Hello, world.\n", stderr: "echo 'Hello, world.'\n", - status: EXIT_SUCCESS, } integration_test! { name: backtick_code_assignment, justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 100 | @@ -477,8 +434,6 @@ integration_test! { integration_test! { name: backtick_code_interpolation, justfile: "b := a\na := `echo hello`\nbar:\n echo '{{`exit 200`}}'", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 200 | @@ -491,8 +446,6 @@ integration_test! { integration_test! { name: backtick_code_interpolation_mod, justfile: "f:\n η„‘{{`exit 200`}}", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 200 | @@ -508,8 +461,6 @@ integration_test! { backtick-fail: \techo {{`exit 1`}} ", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 1 | @@ -525,8 +476,6 @@ integration_test! { backtick-fail: \techo {{\t`exit 1`}} ", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 1 | @@ -542,8 +491,6 @@ integration_test! { backtick-fail: \techo {{\t`exit\t\t1`}} ", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 1 | @@ -559,8 +506,6 @@ integration_test! { backtick-fail: \techo 😬{{`exit 1`}} ", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 1 | @@ -576,8 +521,6 @@ integration_test! { backtick-fail: \techo \t\t\t😬鎌鼬{{\t\t`exit 1 # \t\t\tabc`}}\t\t\t😬鎌鼬 ", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 1 | @@ -590,8 +533,6 @@ backtick-fail: integration_test! { name: backtick_code_long, justfile: "\n\n\n\n\n\nb := a\na := `echo hello`\nbar:\n echo '{{`exit 200`}}'", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 200 | @@ -607,8 +548,6 @@ integration_test! { #!/bin/sh echo hello echo {{`exit 123`}}", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 123 | @@ -623,8 +562,6 @@ integration_test! { justfile: "foo: echo hello echo {{`exit 123`}}", - args: (), - stdin: "", stdout: "hello\n", stderr: "echo hello\nerror: Backtick failed with exit code 123 | @@ -640,8 +577,6 @@ integration_test! { echo hello echo {{`exit 111`}} a := `exit 222`", - args: (), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 222 | @@ -658,7 +593,6 @@ integration_test! { echo {{`exit 111`}} a := `exit 222`", args: ("--set", "foo", "bar", "--set", "baz", "bob", "--set", "a", "b", "a", "b"), - stdin: "", stdout: "", stderr: "error: Variables `baz` and `foo` overridden on the command line but not present \ in justfile\n", @@ -672,7 +606,6 @@ integration_test! { echo {{`exit 111`}} a := `exit 222`", args: ("foo=bar", "baz=bob", "a=b", "a", "b"), - stdin: "", stdout: "", stderr: "error: Variables `baz` and `foo` overridden on the command line but not present \ in justfile\n", @@ -686,7 +619,6 @@ integration_test! { echo {{`exit 111`}} a := `exit 222`", args: ("foo=bar", "a=b", "a", "b"), - stdin: "", stdout: "", stderr: "error: Variable `foo` overridden on the command line but not present in justfile\n", status: EXIT_FAILURE, @@ -703,10 +635,8 @@ recipe arg: echo arg={{arg}} echo {{foo + a + baz}}"#, args: ("foo=bar", "a=b", "recipe", "baz=bar"), - stdin: "", stdout: "arg=baz=bar\nbarbbaz\n", stderr: "echo arg=baz=bar\necho barbbaz\n", - status: EXIT_SUCCESS, } integration_test! { @@ -720,10 +650,8 @@ recipe arg: echo arg={{arg}} echo {{foo + a + baz}}"#, args: ("foo=bar", "a=b", "recipe", "baz=bar"), - stdin: "", stdout: "arg=baz=bar\nbarbbaz\n", stderr: "echo arg=baz=bar\necho barbbaz\n", - status: EXIT_SUCCESS, } integration_test! { @@ -742,7 +670,6 @@ shebang: {{var}} echo {{`echo shebang interpolation`}}"#, args: ("--dry-run", "shebang", "command"), - stdin: "", stdout: "", stderr: "#!/bin/sh touch /this/is/not/a/file @@ -752,7 +679,6 @@ touch /this/is/not/a/file `echo stderr 1>&2; echo backtick` echo `echo command interpolation` ", - status: EXIT_SUCCESS, } integration_test! { @@ -767,14 +693,11 @@ wut: touch /this/is/not/a/file "#, args: ("--evaluate"), - stdin: "", stdout: r#"ab := "a b c" bar := "b " foo := "a " hello := "c" "#, - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -788,11 +711,8 @@ export ABC := FOO + BAR + baz wut: echo $FOO $BAR $ABC "#, - args: (), - stdin: "", stdout: "a b abc\n", stderr: "echo $FOO $BAR $ABC\n", - status: EXIT_SUCCESS, } integration_test! { @@ -807,10 +727,8 @@ wut: echo $FOO $BAR $ABC "#, args: ("--set", "BAR", "bye", "FOO=hello"), - stdin: "", stdout: "hello bye hello-bye-c\n", stderr: "echo $FOO $BAR $ABC\n", - status: EXIT_SUCCESS, } integration_test! { @@ -825,11 +743,7 @@ wut: #!/bin/sh echo $FOO $BAR $ABC "#, - args: (), - stdin: "", stdout: "a b abc\n", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -840,11 +754,8 @@ export EXPORTED_VARIABLE := "A-IS-A" recipe: echo {{`echo recipe $EXPORTED_VARIABLE`}} "#, - args: (), - stdin: "", stdout: "recipe A-IS-A\n", stderr: "echo recipe A-IS-A\n", - status: EXIT_SUCCESS, } integration_test! { @@ -855,11 +766,8 @@ export EXPORTED_VARIABLE := '\z' recipe: printf "$EXPORTED_VARIABLE" "#, - args: (), - stdin: "", stdout: "\\z", stderr: "printf \"$EXPORTED_VARIABLE\"\n", - status: EXIT_SUCCESS, } integration_test! { @@ -875,8 +783,6 @@ integration_test! { ??? "#, - args: (), - stdin: "", stdout: "", stderr: "error: Unknown start of token: | @@ -893,10 +799,7 @@ default: @echo hello "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -906,10 +809,7 @@ default: @echo hello 1>&2 "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -919,10 +819,7 @@ default: exit "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -932,9 +829,7 @@ default: exit 100 "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", status: 100, } @@ -946,9 +841,7 @@ default: exit 100 "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", status: 100, } @@ -960,9 +853,7 @@ default: exit 100 "#, args: ("--quiet"), - stdin: "", stdout: "", - stderr: "", status: 100, } @@ -973,10 +864,8 @@ foo A: echo {{A}} ", args: ("foo", "ARGUMENT"), - stdin: "", stdout: "ARGUMENT\n", stderr: "echo ARGUMENT\n", - status: EXIT_SUCCESS, } integration_test! { @@ -986,10 +875,8 @@ foo A B: echo A:{{A}} B:{{B}} ", args: ("foo", "ONE", "TWO"), - stdin: "", stdout: "A:ONE B:TWO\n", stderr: "echo A:ONE B:TWO\n", - status: EXIT_SUCCESS, } integration_test! { @@ -999,7 +886,6 @@ foo A B: echo A:{{A}} B:{{B}} ", args: ("foo", "ONE", "TWO", "THREE"), - stdin: "", stdout: "", stderr: "error: Justfile does not contain recipe `THREE`.\n", status: EXIT_FAILURE, @@ -1012,7 +898,6 @@ foo A B: echo A:{{A}} B:{{B}} ", args: ("foo", "ONE"), - stdin: "", stdout: "", stderr: "error: Recipe `foo` got 1 argument but takes 2\nusage:\n just foo A B\n", status: EXIT_FAILURE, @@ -1025,7 +910,6 @@ foo A B='B': echo A:{{A}} B:{{B}} ", args: ("foo", "ONE", "TWO", "THREE"), - stdin: "", stdout: "", stderr: "error: Justfile does not contain recipe `THREE`.\n", status: EXIT_FAILURE, @@ -1038,7 +922,6 @@ foo A B C='C': echo A:{{A}} B:{{B}} C:{{C}} ", args: ("foo", "bar"), - stdin: "", stdout: "", stderr: "error: Recipe `foo` got 1 argument but takes at least 2\nusage:\n just foo A B C='C'\n", status: EXIT_FAILURE, @@ -1048,7 +931,6 @@ integration_test! { name: unknown_recipe, justfile: "hello:", args: ("foo"), - stdin: "", stdout: "", stderr: "error: Justfile does not contain recipe `foo`.\n", status: EXIT_FAILURE, @@ -1058,7 +940,6 @@ integration_test! { name: unknown_recipes, justfile: "hello:", args: ("foo", "bar"), - stdin: "", stdout: "", stderr: "error: Justfile does not contain recipes `foo` or `bar`.\n", status: EXIT_FAILURE, @@ -1068,7 +949,6 @@ integration_test! { name: color_always, justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'", args: ("--color", "always"), - stdin: "", stdout: "", stderr: "\u{1b}[1;31merror:\u{1b}[0m \u{1b}[1mBacktick failed with exit code 100 \u{1b}[0m |\n2 | a := `exit 100`\n | \u{1b}[1;31m^^^^^^^^^^\u{1b}[0m\n", @@ -1079,7 +959,6 @@ integration_test! { name: color_never, justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'", args: ("--color", "never"), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 100 | @@ -1093,7 +972,6 @@ integration_test! { name: color_auto, justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'", args: ("--color", "auto"), - stdin: "", stdout: "", stderr: "error: Backtick failed with exit code 100 | @@ -1109,7 +987,6 @@ integration_test! { recipe: @exit 100", args: ("--color=always"), - stdin: "", stdout: "", stderr: "\u{1b}[1;31merror:\u{1b}[0m \u{1b}[1m\ Recipe `recipe` failed on line 3 with exit code 100\u{1b}[0m\n", @@ -1123,20 +1000,15 @@ integration_test! { recipe a b +d: @exit 100"#, args: ("--dump"), - stdin: "", stdout: "# this recipe does something recipe a b +d: @exit 100 ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: mixed_whitespace, justfile: "bar:\n\t echo hello", - args: (), - stdin: "", stdout: "", stderr: "error: Found a mix of tabs and spaces in leading whitespace: `␉␠` Leading whitespace may consist of tabs or spaces, but not both @@ -1150,8 +1022,6 @@ Leading whitespace may consist of tabs or spaces, but not both integration_test! { name: extra_leading_whitespace, justfile: "bar:\n\t\techo hello\n\t\t\techo goodbye", - args: (), - stdin: "", stdout: "", stderr: "error: Recipe line has extra leading whitespace | @@ -1164,8 +1034,6 @@ integration_test! { integration_test! { name: inconsistent_leading_whitespace, justfile: "bar:\n\t\techo hello\n\t echo goodbye", - args: (), - stdin: "", stdout: "", stderr: "error: Recipe line has inconsistent leading whitespace. \ Recipe started with `␉␉` but found line with `␉␠` @@ -1179,8 +1047,6 @@ integration_test! { integration_test! { name: required_after_default, justfile: "bar:\nhello baz arg='foo' bar:", - args: (), - stdin: "", stdout: "", stderr: "error: Non-default parameter `bar` follows default parameter | @@ -1193,8 +1059,6 @@ integration_test! { integration_test! { name: required_after_variadic, justfile: "bar:\nhello baz +arg bar:", - args: (), - stdin: "", stdout: "", stderr: "error: Parameter `bar` follows variadic parameter | @@ -1212,10 +1076,8 @@ hello baz arg="XYZ\t\" ": echo '{{baz}}...{{arg}}' "#, args: ("hello", "ABC"), - stdin: "", stdout: "ABC...XYZ\t\"\t\n", stderr: "echo 'ABC...XYZ\t\"\t'\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1226,10 +1088,8 @@ hello baz arg='XYZ" ': printf '{{baz}}...{{arg}}' "#, args: ("hello", "ABC"), - stdin: "", stdout: "ABC...XYZ\"\t", stderr: "printf 'ABC...XYZ\"\t'\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1239,10 +1099,8 @@ hello a b='B' c='C': echo {{a}} {{b}} {{c}} "#, args: ("hello", "0", "1"), - stdin: "", stdout: "0 1 C\n", stderr: "echo 0 1 C\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1252,10 +1110,8 @@ hello a b='B' c='C': echo {{a}} {{b}} {{c}} "#, args: ("hello", "0", "1", "2"), - stdin: "", stdout: "0 1 2\n", stderr: "echo 0 1 2\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1274,13 +1130,10 @@ a Z="\t z": _private-recipe: "#, args: ("--list"), - stdin: "", stdout: r#"Available recipes: a Z="\t z" hello a b='B ' c='C' # this does a thing "#, - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -1298,13 +1151,10 @@ a Z="\t z": _private-recipe: "#, args: ("--list"), - stdin: "", stdout: r#"Available recipes: a Z="\t z" # something else hello a b='B ' c='C' # this does a thing "#, - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -1326,14 +1176,11 @@ this-recipe-is-very-very-very-important Z="\t z": _private-recipe: "#, args: ("--list"), - stdin: "", stdout: r#"Available recipes: hello a b='B ' c='C' # this does a thing this-recipe-is-very-very-very-important Z="\t z" # something else x a b='B ' c='C' # this does another thing "#, - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -1345,7 +1192,6 @@ hello a b='B ' c='C': a Z="\t z": "#, args: ("--show", "hell"), - stdin: "", stdout: "", stderr: "Justfile does not contain recipe `hell`.\nDid you mean `hello`?\n", status: EXIT_FAILURE, @@ -1360,7 +1206,6 @@ helloooooo a b='B ' c='C': a Z="\t z": "#, args: ("--show", "hell"), - stdin: "", stdout: "", stderr: "Justfile does not contain recipe `hell`.\n", status: EXIT_FAILURE, @@ -1375,7 +1220,6 @@ hello a b='B ' c='C': a Z="\t z": "#, args: ("hell"), - stdin: "", stdout: "", stderr: "error: Justfile does not contain recipe `hell`.\nDid you mean `hello`?\n", status: EXIT_FAILURE, @@ -1389,11 +1233,8 @@ foo: b \ c "#, - args: (), - stdin: "", stdout: "a b c\n", stderr: "echo a b c\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1404,11 +1245,8 @@ foo: b \ c' "#, - args: (), - stdin: "", stdout: "a b c\n", stderr: "echo 'a b c'\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1419,11 +1257,8 @@ foo: b\ c "#, - args: (), - stdin: "", stdout: "abc\n", stderr: "echo abc\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1432,11 +1267,8 @@ integration_test! { foo: echo {{arch()}} {{os()}} {{os_family()}} "#, - args: (), - stdin: "", stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), - status: EXIT_SUCCESS, } integration_test! { @@ -1449,11 +1281,8 @@ f := os_family() foo: echo {{a}} {{o}} {{f}} "#, - args: (), - stdin: "", stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), - status: EXIT_SUCCESS, } #[cfg(not(windows))] @@ -1467,11 +1296,8 @@ x := env_var_or_default('XYZ', 'ABC') foo: /bin/echo '{{p}}' '{{b}}' '{{x}}' "#, - args: (), - stdin: "", stdout: format!("{} HTAP ABC\n", env::var("USER").unwrap()).as_str(), stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("USER").unwrap()).as_str(), - status: EXIT_SUCCESS, } #[cfg(windows)] @@ -1485,18 +1311,14 @@ x := env_var_or_default('XYZ', 'ABC') foo: /bin/echo '{{p}}' '{{b}}' '{{x}}' "#, - args: (), - stdin: "", stdout: format!("{} HTAP ABC\n", env::var("USERNAME").unwrap()).as_str(), stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("USERNAME").unwrap()).as_str(), - status: EXIT_SUCCESS, } integration_test! { name: env_var_failure, justfile: "a:\n echo {{env_var('ZADDY')}}", args: ("a"), - stdin: "", stdout: "", stderr: "error: Call to function `env_var` failed: environment variable `ZADDY` not present | @@ -1514,11 +1336,8 @@ integration_test! { # b @echo c "#, - args: (), - stdin: "", stdout: "c\n", stderr: "echo c\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1528,11 +1347,8 @@ integration_test! { #!/bin/sh echo hello "#, - args: (), - stdin: "", stdout: "hello\n", stderr: "#!/bin/sh\necho hello\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1550,8 +1366,6 @@ quiet: "#, - args: (), - stdin: "", stdout: "#!/usr/bin/env cat @@ -1563,8 +1377,6 @@ b c ", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -1575,17 +1387,13 @@ b: c: b a "#, args: ("b"), - stdin: "", stdout: "", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { name: parameter_shadows_variable, justfile: "FOO := 'hello'\na FOO:", args: ("a"), - stdin: "", stdout: "", stderr: "error: Parameter `FOO` shadows variable of the same name | @@ -1600,7 +1408,6 @@ integration_test! { justfile: r#"foo := foo() + "hello" bar:"#, args: ("bar"), - stdin: "", stdout: "", stderr: r#"error: Call to unknown function `foo` | @@ -1614,7 +1421,6 @@ integration_test! { name: dependency_takes_arguments, justfile: "b: a\na FOO:", args: ("b"), - stdin: "", stdout: "", stderr: "error: Recipe `b` depends on `a` which requires arguments. \ Dependencies may not require arguments @@ -1629,7 +1435,6 @@ integration_test! { name: duplicate_parameter, justfile: "a foo foo:", args: ("a"), - stdin: "", stdout: "", stderr: "error: Recipe `a` has duplicate parameter `foo` | @@ -1643,7 +1448,6 @@ integration_test! { name: duplicate_dependency, justfile: "b:\na: b b", args: ("a"), - stdin: "", stdout: "", stderr: "error: Recipe `a` has duplicate dependency `b` | @@ -1657,7 +1461,6 @@ integration_test! { name: duplicate_recipe, justfile: "b:\nb:", args: ("b"), - stdin: "", stdout: "", stderr: "error: Recipe `b` first defined on line 1 is redefined on line 2 | @@ -1671,7 +1474,6 @@ integration_test! { name: duplicate_variable, justfile: "a := 'hello'\na := 'hello'\nfoo:", args: ("foo"), - stdin: "", stdout: "", stderr: "error: Variable `a` has multiple definitions | @@ -1685,7 +1487,6 @@ integration_test! { name: unexpected_token_in_dependency_position, justfile: "foo: 'bar'", args: ("foo"), - stdin: "", stdout: "", stderr: "error: Expected name, end of line, or end of file, but found raw string | @@ -1699,7 +1500,6 @@ integration_test! { name: unexpected_token_after_name, justfile: "foo 'bar'", args: ("foo"), - stdin: "", stdout: "", stderr: "error: Expected name, '+', ':', or ':=', but found raw string | @@ -1713,7 +1513,6 @@ integration_test! { name: self_dependency, justfile: "a: a", args: ("a"), - stdin: "", stdout: "", stderr: "error: Recipe `a` depends on itself | @@ -1727,7 +1526,6 @@ integration_test! { name: long_circular_recipe_dependency, justfile: "a: b\nb: c\nc: d\nd: a", args: ("a"), - stdin: "", stdout: "", stderr: "error: Recipe `d` has circular dependency `a -> b -> c -> d -> a` | @@ -1741,7 +1539,6 @@ integration_test! { name: variable_self_dependency, justfile: "z := z\na:", args: ("a"), - stdin: "", stdout: "", stderr: "error: Variable `z` is defined in terms of itself | @@ -1755,7 +1552,6 @@ integration_test! { name: variable_circular_dependency, justfile: "x := y\ny := z\nz := x\na:", args: ("a"), - stdin: "", stdout: "", stderr: "error: Variable `x` depends on its own value: `x -> y -> z -> x` | @@ -1770,7 +1566,6 @@ integration_test! { justfile: r#"x := "\q" a:"#, args: ("a"), - stdin: "", stdout: "", stderr: "error: `\\q` is not a valid escape sequence | @@ -1790,14 +1585,12 @@ a: echo '{{string}}' ", args: ("a"), - stdin: "", stdout: "hello whatever ", stderr: "echo 'hello whatever' ", - status: EXIT_SUCCESS, } integration_test! { @@ -1811,7 +1604,6 @@ a: echo '{{foo}}' ", args: ("a"), - stdin: "", stdout: "", stderr: "error: Variable `foo` not defined | @@ -1832,7 +1624,6 @@ a: echo '{{string}}' ", args: ("a"), - stdin: "", stdout: "", stderr: "error: Variable `bar` not defined | @@ -1850,14 +1641,12 @@ a: ' + "b"}}' "#, args: ("a"), - stdin: "", stdout: "a b ", stderr: "echo 'a b' ", - status: EXIT_SUCCESS, } integration_test! { @@ -1870,7 +1659,6 @@ a: echo {{b}} "#, args: ("a"), - stdin: "", stdout: "", stderr: "error: Variable `b` not defined | @@ -1886,7 +1674,6 @@ integration_test! { a b= ': ", args: ("a"), - stdin: "", stdout: "", stderr: "error: Unterminated string | @@ -1902,7 +1689,6 @@ integration_test! { a b= ": "#, args: ("a"), - stdin: "", stdout: "", stderr: r#"error: Unterminated string | @@ -1919,10 +1705,8 @@ a x y +z: echo {{x}} {{y}} {{z}} ", args: ("a", "0", "1", "2", "3", " 4 "), - stdin: "", stdout: "0 1 2 3 4\n", stderr: "echo 0 1 2 3 4 \n", - status: EXIT_SUCCESS, } integration_test! { @@ -1932,10 +1716,8 @@ a x y +z='HELLO': echo {{x}} {{y}} {{z}} ", args: ("a", "0", "1", "2", "3", " 4 "), - stdin: "", stdout: "0 1 2 3 4\n", stderr: "echo 0 1 2 3 4 \n", - status: EXIT_SUCCESS, } integration_test! { @@ -1945,10 +1727,8 @@ a x y +z='HELLO': echo {{x}} {{y}} {{z}} ", args: ("a", "0", "1"), - stdin: "", stdout: "0 1 HELLO\n", stderr: "echo 0 1 HELLO\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1958,7 +1738,6 @@ a x y +z: echo {{x}} {{y}} {{z}} ", args: ("a", "0", "1"), - stdin: "", stdout: "", stderr: "error: Recipe `a` got 2 arguments but takes at least 3\nusage:\n just a x y +z\n", status: EXIT_FAILURE, @@ -1977,10 +1756,8 @@ BAZ +Z: echo baz: {{Z}} ", args: ("BAR", "0", "FOO", "1", "2", "BAZ", "3", "4", "5"), - stdin: "", stdout: "bar: 0\nfoo: 1 2\nbaz: 3 4 5\n", stderr: "echo bar: 0\necho foo: 1 2\necho baz: 3 4 5\n", - status: EXIT_SUCCESS, } integration_test! { @@ -1990,8 +1767,6 @@ x: a: x y ", - args: (), - stdin: "", stdout: "", stderr: "error: Recipe `a` has unknown dependency `y` | @@ -2009,13 +1784,10 @@ a B C +D='hello': echo {{B}} {{C}} {{D}} ", args: ("--color", "always", "--list"), - stdin: "", stdout: "Available recipes:\n a \ \u{1b}[36mB\u{1b}[0m \u{1b}[36mC\u{1b}[0m \u{1b}[35m+\ \u{1b}[0m\u{1b}[36mD\u{1b}[0m=\u{1b}[32m'hello'\u{1b}[0m \ \u{1b}[34m#\u{1b}[0m \u{1b}[34mcomment\u{1b}[0m\n", - stderr: "", - status: EXIT_SUCCESS, } integration_test! { @@ -2026,10 +1798,8 @@ a: echo hi ", args: ("--color", "always", "--highlight", "--verbose"), - stdin: "", stdout: "hi\n", stderr: "\u{1b}[1;36m===> Running recipe `a`...\u{1b}[0m\n\u{1b}[1mecho hi\u{1b}[0m\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2039,10 +1809,8 @@ echo A B C: echo {{A}} {{B}} {{C}} ", args: ("echo", "--some", "--awesome", "--flags"), - stdin: "", stdout: "--some --awesome --flags\n", stderr: "echo --some --awesome --flags\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2054,10 +1822,8 @@ echo: echo {{A}} ", args: ("echo"), - stdin: "", stdout: "1\n", stderr: "echo 1\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2067,11 +1833,8 @@ integration_test! { echo: echo $DOTENV_KEY ", - args: (), - stdin: "", stdout: "dotenv-value\n", stderr: "echo $DOTENV_KEY\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2082,11 +1845,8 @@ X:=`echo $DOTENV_KEY` echo: echo {{X}} ", - args: (), - stdin: "", stdout: "dotenv-value\n", stderr: "echo dotenv-value\n", - status: EXIT_SUCCESS, } integration_test! { name: dotenv_variable_in_function_in_recipe, @@ -2096,11 +1856,8 @@ echo: echo {{env_var_or_default('DOTENV_KEY', 'foo')}} echo {{env_var('DOTENV_KEY')}} ", - args: (), - stdin: "", stdout: "dotenv-value\ndotenv-value\n", stderr: "echo dotenv-value\necho dotenv-value\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2113,11 +1870,8 @@ echo: echo {{X}} echo {{Y}} ", - args: (), - stdin: "", stdout: "dotenv-value\ndotenv-value\n", stderr: "echo dotenv-value\necho dotenv-value\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2125,8 +1879,6 @@ integration_test! { justfile: r#" X := "\'" "#, - args: (), - stdin: "", stdout: "", stderr: r#"error: `\'` is not a valid escape sequence | @@ -2141,8 +1893,6 @@ integration_test! { justfile: " foo x=bar: ", - args: (), - stdin: "", stdout: "", stderr: r#"error: Variable `bar` not defined | @@ -2157,8 +1907,6 @@ integration_test! { justfile: " foo x=bar(): ", - args: (), - stdin: "", stdout: "", stderr: r#"error: Call to unknown function `bar` | @@ -2174,11 +1922,8 @@ integration_test! { foo x='bar': echo {{x}} ", - args: (), - stdin: "", stdout: "bar\n", stderr: "echo bar\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2187,11 +1932,8 @@ integration_test! { foo x=(`echo foo` + 'bar'): echo {{x}} ", - args: (), - stdin: "", stdout: "foobar\n", stderr: "echo foobar\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2200,11 +1942,8 @@ integration_test! { foo x=`echo foo`: echo {{x}} ", - args: (), - stdin: "", stdout: "foo\n", stderr: "echo foo\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2214,11 +1953,8 @@ y := 'foo' foo x=y: echo {{x}} ", - args: (), - stdin: "", stdout: "foo\n", stderr: "echo foo\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2227,11 +1963,8 @@ integration_test! { foo a=arch() o=os() f=os_family(): echo {{a}} {{o}} {{f}} "#, - args: (), - stdin: "", stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(), - status: EXIT_SUCCESS, } integration_test! { @@ -2240,8 +1973,6 @@ integration_test! { foo: echo {{ ", - args: (), - stdin: "", stdout: "", stderr: r#"error: Unterminated interpolation | @@ -2256,8 +1987,6 @@ integration_test! { justfile: " foo: echo {{", - args: (), - stdin: "", stdout: "", stderr: r#"error: Unterminated interpolation | @@ -2272,8 +2001,6 @@ integration_test! { justfile: " foo a=\t`echo blaaaaaah: echo {{a}}", - args: (), - stdin: "", stdout: "", stderr: r#"error: Unterminated backtick | @@ -2288,8 +2015,6 @@ integration_test! { justfile: " assembly_source_files = $(wildcard src/arch/$(arch)/*.s) ", - args: (), - stdin: "", stdout: "", stderr: r#"error: Unknown start of token: | @@ -2307,11 +2032,9 @@ stdin := `cat` default: echo {{stdin}} ", - args: (), stdin: "STDIN", stdout: "STDIN\n", stderr: "echo STDIN\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2320,11 +2043,9 @@ integration_test! { default stdin = `cat`: echo {{stdin}} ", - args: (), stdin: "STDIN", stdout: "STDIN\n", stderr: "echo STDIN\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2333,8 +2054,6 @@ integration_test! { default stdin = `cat justfile`: echo '{{stdin}}' ", - args: (), - stdin: "", stdout: " default stdin = `cat justfile`: echo {{stdin}} @@ -2342,7 +2061,6 @@ default stdin = `cat justfile`: stderr: "echo ' default stdin = `cat justfile`: echo '{{stdin}}''\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2353,11 +2071,9 @@ password := `read PW && echo $PW` default: echo {{password}} ", - args: (), stdin: "foobar\n", stdout: "foobar\n", stderr: "echo foobar\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2370,11 +2086,9 @@ default: echo {{a}} echo {{b}} ", - args: (), stdin: "foo\nbar\n", stdout: "foo\nbar\n", stderr: "echo foo\necho bar\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2385,11 +2099,9 @@ default a=`read A && echo $A` b=`read B && echo $B`: echo {{a}} echo {{b}} ", - args: (), stdin: "foo\nbar\n", stdout: "foo\nbar\n", stderr: "echo foo\necho bar\n", - status: EXIT_SUCCESS, } integration_test! { @@ -2402,8 +2114,6 @@ default: echo {{foo}} ", - args: (), - stdin: "", stdout: "bar\n", stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=` Please see this issue for more details: https://github.com/casey/just/issues/379 @@ -2412,7 +2122,6 @@ Please see this issue for more details: https://github.com/casey/just/issues/379 | ^ echo bar ", - status: EXIT_SUCCESS, } integration_test! { @@ -2425,8 +2134,6 @@ default: echo $FOO ", - args: (), - stdin: "", stdout: "bar\n", stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=` Please see this issue for more details: https://github.com/casey/just/issues/379 @@ -2435,7 +2142,6 @@ Please see this issue for more details: https://github.com/casey/just/issues/379 | ^ echo $FOO ", - status: EXIT_SUCCESS, } integration_test! { @@ -2449,7 +2155,6 @@ default: ", args: ("foo"), - stdin: "", stdout: "default\n", stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=` Please see this issue for more details: https://github.com/casey/just/issues/379 @@ -2458,5 +2163,4 @@ Please see this issue for more details: https://github.com/casey/just/issues/379 | ^ echo default ", - status: EXIT_SUCCESS, }