2021-04-25 04:29:58 +03:00
|
|
|
test! {
|
|
|
|
name: linewise,
|
|
|
|
justfile: r#"
|
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo bar baz:
|
|
|
|
echo $0
|
|
|
|
echo $1
|
|
|
|
echo $2
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
args: ("foo", "hello", "goodbye"),
|
|
|
|
stdout: "
|
|
|
|
foo
|
|
|
|
hello
|
|
|
|
goodbye
|
|
|
|
hello goodbye
|
|
|
|
",
|
|
|
|
stderr: r#"
|
|
|
|
echo $0
|
|
|
|
echo $1
|
|
|
|
echo $2
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
}
|
|
|
|
|
2024-06-13 22:35:14 +03:00
|
|
|
test! {
|
|
|
|
name: linewise_with_attribute,
|
|
|
|
justfile: r#"
|
|
|
|
[positional-arguments]
|
|
|
|
foo bar baz:
|
|
|
|
echo $0
|
|
|
|
echo $1
|
|
|
|
echo $2
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
args: ("foo", "hello", "goodbye"),
|
|
|
|
stdout: "
|
|
|
|
foo
|
|
|
|
hello
|
|
|
|
goodbye
|
|
|
|
hello goodbye
|
|
|
|
",
|
|
|
|
stderr: r#"
|
|
|
|
echo $0
|
|
|
|
echo $1
|
|
|
|
echo $2
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
}
|
|
|
|
|
2021-04-25 04:29:58 +03:00
|
|
|
test! {
|
|
|
|
name: variadic_linewise,
|
|
|
|
justfile: r#"
|
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo *bar:
|
|
|
|
echo $1
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
args: ("foo", "a", "b", "c"),
|
|
|
|
stdout: "a\na b c\n",
|
|
|
|
stderr: "echo $1\necho \"$@\"\n",
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: shebang,
|
|
|
|
justfile: "
|
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo bar:
|
|
|
|
#!/bin/sh
|
|
|
|
echo $1
|
|
|
|
",
|
|
|
|
args: ("foo", "hello"),
|
|
|
|
stdout: "hello\n",
|
|
|
|
}
|
|
|
|
|
2024-06-13 22:35:14 +03:00
|
|
|
test! {
|
|
|
|
name: shebang_with_attribute,
|
|
|
|
justfile: "
|
|
|
|
[positional-arguments]
|
|
|
|
foo bar:
|
|
|
|
#!/bin/sh
|
|
|
|
echo $1
|
|
|
|
",
|
|
|
|
args: ("foo", "hello"),
|
|
|
|
stdout: "hello\n",
|
|
|
|
}
|
|
|
|
|
2021-04-25 04:29:58 +03:00
|
|
|
test! {
|
|
|
|
name: variadic_shebang,
|
|
|
|
justfile: r#"
|
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo *bar:
|
|
|
|
#!/bin/sh
|
|
|
|
echo $1
|
|
|
|
echo "$@"
|
|
|
|
"#,
|
|
|
|
args: ("foo", "a", "b", "c"),
|
|
|
|
stdout: "a\na b c\n",
|
|
|
|
}
|
2021-05-02 13:25:43 +03:00
|
|
|
|
|
|
|
test! {
|
|
|
|
name: default_arguments,
|
2024-07-28 01:00:19 +03:00
|
|
|
justfile: r"
|
2021-05-02 13:25:43 +03:00
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo bar='baz':
|
|
|
|
echo $1
|
2024-07-28 01:00:19 +03:00
|
|
|
",
|
2021-05-02 13:25:43 +03:00
|
|
|
args: (),
|
|
|
|
stdout: "baz\n",
|
|
|
|
stderr: "echo $1\n",
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: empty_variadic_is_undefined,
|
|
|
|
justfile: r#"
|
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo *bar:
|
|
|
|
if [ -n "${1+1}" ]; then echo defined; else echo undefined; fi
|
|
|
|
"#,
|
|
|
|
args: (),
|
|
|
|
stdout: "undefined\n",
|
|
|
|
stderr: "if [ -n \"${1+1}\" ]; then echo defined; else echo undefined; fi\n",
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: variadic_arguments_are_separate,
|
2024-07-28 01:00:19 +03:00
|
|
|
justfile: r"
|
2021-05-02 13:25:43 +03:00
|
|
|
set positional-arguments
|
|
|
|
|
|
|
|
foo *bar:
|
|
|
|
echo $1
|
|
|
|
echo $2
|
2024-07-28 01:00:19 +03:00
|
|
|
",
|
2021-05-02 13:25:43 +03:00
|
|
|
args: ("foo", "a", "b"),
|
|
|
|
stdout: "a\nb\n",
|
|
|
|
stderr: "echo $1\necho $2\n",
|
|
|
|
}
|