2022-10-31 00:52:03 -07:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn all() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[macos]
|
|
|
|
[windows]
|
|
|
|
[linux]
|
|
|
|
[unix]
|
|
|
|
[no-exit-message]
|
|
|
|
foo:
|
|
|
|
exit 1
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr("exit 1\n")
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn duplicate_attributes_are_disallowed() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[no-exit-message]
|
|
|
|
[no-exit-message]
|
|
|
|
foo:
|
|
|
|
echo bar
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr(
|
|
|
|
"
|
|
|
|
error: Recipe attribute `no-exit-message` first used on line 1 is duplicated on line 2
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:2:2
|
|
|
|
│
|
|
|
|
2 │ [no-exit-message]
|
|
|
|
│ ^^^^^^^^^^^^^^^
|
2022-10-31 00:52:03 -07:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
2023-01-26 23:54:24 -08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiple_attributes_one_line() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[macos, windows,linux]
|
|
|
|
[no-exit-message]
|
|
|
|
foo:
|
|
|
|
exit 1
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr("exit 1\n")
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiple_attributes_one_line_error_message() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[macos, windows linux]
|
|
|
|
[no-exit-message]
|
|
|
|
foo:
|
|
|
|
exit 1
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr(
|
|
|
|
"
|
2024-06-06 09:45:00 -07:00
|
|
|
error: Expected ']', ':', ',', or '(', but found identifier
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:1:17
|
|
|
|
│
|
|
|
|
1 │ [macos, windows linux]
|
|
|
|
│ ^^^^^
|
2023-01-26 23:54:24 -08:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiple_attributes_one_line_duplicate_check() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[macos, windows, linux]
|
|
|
|
[linux]
|
|
|
|
foo:
|
|
|
|
exit 1
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr(
|
|
|
|
"
|
|
|
|
error: Recipe attribute `linux` first used on line 1 is duplicated on line 2
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:2:2
|
|
|
|
│
|
|
|
|
2 │ [linux]
|
|
|
|
│ ^^^^^
|
2023-01-26 23:54:24 -08:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
2024-01-12 18:44:13 -08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unexpected_attribute_argument() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[private('foo')]
|
|
|
|
foo:
|
|
|
|
exit 1
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.stderr(
|
|
|
|
"
|
2024-05-25 00:32:25 -07:00
|
|
|
error: Attribute `private` got 1 argument but takes 0 arguments
|
2024-01-12 18:44:13 -08:00
|
|
|
——▶ justfile:1:2
|
|
|
|
│
|
|
|
|
1 │ [private('foo')]
|
|
|
|
│ ^^^^^^^
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
2024-05-25 02:26:04 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn doc_attribute() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
# Non-document comment
|
|
|
|
[doc('The real docstring')]
|
|
|
|
foo:
|
|
|
|
echo foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo # The real docstring
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn doc_attribute_suppress() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
2024-05-25 18:12:55 -07:00
|
|
|
# Non-document comment
|
|
|
|
[doc]
|
|
|
|
foo:
|
|
|
|
echo foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn doc_multiline() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[doc('multiline
|
|
|
|
comment')]
|
|
|
|
foo:
|
|
|
|
",
|
2024-05-25 02:26:04 -07:00
|
|
|
)
|
|
|
|
.args(["--list"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
2024-05-25 18:12:55 -07:00
|
|
|
# multiline
|
|
|
|
# comment
|
2024-05-25 02:26:04 -07:00
|
|
|
foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|