Skip to content

Commit

Permalink
Convert run_shebang into integration test (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 26, 2024
1 parent d1e2ef7 commit 5a36e68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
23 changes: 23 additions & 0 deletions tests/shebang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 5a36e68

Please sign in to comment.