mirror of
https://github.com/casey/just.git
synced 2024-11-23 11:04:09 +03:00
Add test for shebang recipes
This commit is contained in:
parent
72921c0fa8
commit
b7f7deb4bb
28
src/tests.rs
28
src/tests.rs
@ -86,7 +86,7 @@ fn inconsistent_leading_whitespace() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shebang() {
|
||||
fn shebang_errors() {
|
||||
expect_error("#!/bin/sh", 0, ErrorKind::OuterShebang);
|
||||
expect_error("a:\n echo hello\n #!/bin/sh", 2, ErrorKind::NonLeadingShebang{recipe:"a"});
|
||||
}
|
||||
@ -154,7 +154,7 @@ fn code_error() {
|
||||
assert_eq!(recipe, "fail");
|
||||
assert_eq!(code, 100);
|
||||
},
|
||||
other @ _ => panic!("expected an code run error, but got: {}", other),
|
||||
other @ _ => panic!("expected a code run error, but got: {}", other),
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,3 +178,27 @@ d: c
|
||||
super::std::env::set_current_dir(path).expect("failed to set current directory");
|
||||
expect_success(text).run(&["a", "d"]).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shebang() {
|
||||
// this test exists to make sure that shebang recipes
|
||||
// are run correctly. although it is still executed
|
||||
// by sh its behavior depends on the value of a
|
||||
// variable, which would not be available if it were
|
||||
// a plain recipe
|
||||
let text = "
|
||||
a:
|
||||
#!/usr/bin/env sh
|
||||
code=200
|
||||
function x { return $code; }
|
||||
x
|
||||
";
|
||||
|
||||
match expect_success(text).run(&["a"]).unwrap_err() {
|
||||
super::RunError::Code{recipe, code} => {
|
||||
assert_eq!(recipe, "a");
|
||||
assert_eq!(code, 200);
|
||||
},
|
||||
other @ _ => panic!("expected an code run error, but got: {}", other),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user