2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2020-10-26 18:16:42 -07:00
|
|
|
|
2022-12-20 00:44:19 -08:00
|
|
|
test! {
|
2023-11-21 20:17:38 -08:00
|
|
|
name: invalid_alias_attribute,
|
|
|
|
justfile: "[private]\n[linux]\nalias t := test\n\ntest:\n",
|
|
|
|
stderr: "
|
|
|
|
error: Alias t has an invalid attribute `linux`
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:3:7
|
|
|
|
│
|
|
|
|
3 │ alias t := test
|
|
|
|
│ ^
|
2023-11-21 20:17:38 -08:00
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
2022-12-20 00:44:19 -08:00
|
|
|
}
|
|
|
|
|
2020-10-26 18:16:42 -07:00
|
|
|
test! {
|
|
|
|
name: expected_keyword,
|
|
|
|
justfile: "foo := if '' == '' { '' } arlo { '' }",
|
|
|
|
stderr: "
|
|
|
|
error: Expected keyword `else` but found identifier `arlo`
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:1:27
|
|
|
|
│
|
|
|
|
1 │ foo := if '' == '' { '' } arlo { '' }
|
|
|
|
│ ^^^^
|
2020-10-26 18:16:42 -07:00
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: unexpected_character,
|
2023-01-12 19:25:28 -08:00
|
|
|
justfile: "&~",
|
2020-10-26 18:16:42 -07:00
|
|
|
stderr: "
|
2023-01-12 19:25:28 -08:00
|
|
|
error: Expected character `&`
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:1:2
|
|
|
|
│
|
|
|
|
1 │ &~
|
|
|
|
│ ^
|
2020-10-26 18:16:42 -07:00
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2021-07-28 18:27:47 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn argument_count_mismatch() {
|
|
|
|
Test::new()
|
|
|
|
.justfile("foo a b:")
|
2023-01-03 22:31:56 -08:00
|
|
|
.args(["foo"])
|
2021-07-28 18:27:47 -07:00
|
|
|
.stderr(
|
|
|
|
"
|
|
|
|
error: Recipe `foo` got 0 arguments but takes 2
|
|
|
|
usage:
|
|
|
|
just foo a b
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.status(EXIT_FAILURE)
|
|
|
|
.run();
|
|
|
|
}
|
2023-11-21 20:17:38 -08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn file_path_is_indented_if_justfile_is_long() {
|
|
|
|
Test::new()
|
|
|
|
.justfile("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfoo")
|
|
|
|
.status(EXIT_FAILURE)
|
|
|
|
.stderr(
|
|
|
|
"
|
|
|
|
error: Expected '*', ':', '$', identifier, or '+', but found end of file
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:20:4
|
|
|
|
│
|
|
|
|
20 │ foo
|
|
|
|
│ ^
|
2023-11-21 20:17:38 -08:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn file_paths_are_relative() {
|
|
|
|
Test::new()
|
2023-12-19 20:31:51 -08:00
|
|
|
.justfile("import 'foo/bar.just'")
|
2023-11-21 20:17:38 -08:00
|
|
|
.write("foo/bar.just", "baz")
|
|
|
|
.status(EXIT_FAILURE)
|
|
|
|
.stderr(format!(
|
|
|
|
"
|
|
|
|
error: Expected '*', ':', '$', identifier, or '+', but found end of file
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ foo{}bar.just:1:4
|
|
|
|
│
|
|
|
|
1 │ baz
|
|
|
|
│ ^
|
2023-11-21 20:17:38 -08:00
|
|
|
",
|
|
|
|
MAIN_SEPARATOR
|
|
|
|
))
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2023-12-29 13:25:30 -08:00
|
|
|
#[cfg(not(windows))]
|
2023-11-21 20:17:38 -08:00
|
|
|
fn file_paths_not_in_subdir_are_absolute() {
|
|
|
|
Test::new()
|
2023-12-19 20:31:51 -08:00
|
|
|
.write("foo/justfile", "import '../bar.just'")
|
2023-11-21 20:17:38 -08:00
|
|
|
.write("bar.just", "baz")
|
|
|
|
.no_justfile()
|
2023-12-19 20:31:51 -08:00
|
|
|
.args(["--justfile", "foo/justfile"])
|
2023-11-21 20:17:38 -08:00
|
|
|
.status(EXIT_FAILURE)
|
2023-12-29 13:25:30 -08:00
|
|
|
.stderr_regex(
|
|
|
|
r"error: Expected '\*', ':', '\$', identifier, or '\+', but found end of file
|
|
|
|
——▶ /.*/bar.just:1:4
|
|
|
|
│
|
|
|
|
1 │ baz
|
|
|
|
│ \^
|
2023-11-21 20:17:38 -08:00
|
|
|
",
|
2023-12-29 13:25:30 -08:00
|
|
|
)
|
2023-11-21 20:17:38 -08:00
|
|
|
.run();
|
|
|
|
}
|