diff options
author | Casey Rodarmor <casey@rodarmor.com> | 2024-01-26 13:05:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 13:05:32 -0800 |
commit | 5a36e685e59fe1f3d891acdafe61e177033b6e78 (patch) | |
tree | d41a5d35d9484cb38934bec63ef387c3e1ce960e | |
parent | d1e2ef788f054dd15ad97087247e2481e725c286 (diff) |
Convert run_shebang into integration test (#1880)
-rw-r--r-- | src/justfile.rs | 30 | ||||
-rw-r--r-- | tests/shebang.rs | 23 |
2 files changed, 23 insertions, 30 deletions
diff --git a/src/justfile.rs b/src/justfile.rs index 84e1c2be..f8f24550 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -565,36 +565,6 @@ mod tests { } } - // This test exists to make sure that shebang recipes run correctly. Although - // this script is still executed by a shell its behavior depends on the value of - // a variable and continuing even though a command fails, whereas in plain - // recipes variables are not available in subsequent lines and execution stops - // when a line fails. - run_error! { - name: run_shebang, - src: " - a: - #!/usr/bin/env sh - code=200 - x() { return $code; } - x - x - ", - args: ["a"], - error: Code { - recipe, - line_number, - code, - print_message, - }, - check: { - assert_eq!(recipe, "a"); - assert_eq!(code, 200); - assert_eq!(line_number, None); - assert!(print_message); - } - } - run_error! { name: code_error, src: " diff --git a/tests/shebang.rs b/tests/shebang.rs index 04451b73..986d0ca6 100644 --- a/tests/shebang.rs +++ b/tests/shebang.rs @@ -57,3 +57,26 @@ fn simple() { .stdout("bar\n") .run(); } + +// This test exists to make sure that shebang recipes run correctly. Although +// this script is still executed by a shell its behavior depends on the value of +// a variable and continuing even though a command fails, whereas in plain +// recipes variables are not available in subsequent lines and execution stops +// when a line fails. +#[test] +fn run_shebang() { + Test::new() + .justfile( + " + a: + #!/usr/bin/env sh + code=200 + x() { return $code; } + x + x + ", + ) + .status(200) + .stderr("error: Recipe `a` failed with exit code 200\n") + .run(); +} |