-
Notifications
You must be signed in to change notification settings - Fork 540
/
Copy patherror_messages.rs
141 lines (133 loc) Β· 2.63 KB
/
error_messages.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use super::*;
#[test]
fn invalid_alias_attribute() {
Test::new()
.justfile("[private]\n[linux]\nalias t := test\n\ntest:\n")
.stderr(
"
error: Alias `t` has invalid attribute `linux`
βββΆ justfile:3:7
β
3 β alias t := test
β ^
",
)
.status(EXIT_FAILURE)
.run();
}
#[test]
fn expected_keyword() {
Test::new()
.justfile("foo := if '' == '' { '' } arlo { '' }")
.stderr(
"
error: Expected keyword `else` but found identifier `arlo`
βββΆ justfile:1:27
β
1 β foo := if '' == '' { '' } arlo { '' }
β ^^^^
",
)
.status(EXIT_FAILURE)
.run();
}
#[test]
fn unexpected_character() {
Test::new()
.justfile("&~")
.stderr(
"
error: Expected character `&`
βββΆ justfile:1:2
β
1 β &~
β ^
",
)
.status(EXIT_FAILURE)
.run();
}
#[test]
fn argument_count_mismatch() {
Test::new()
.justfile("foo a b:")
.args(["foo"])
.stderr(
"
error: Recipe `foo` got 0 arguments but takes 2
usage:
just foo a b
",
)
.status(EXIT_FAILURE)
.run();
}
#[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
βββΆ justfile:20:4
β
20 β foo
β ^
",
)
.run();
}
#[test]
fn file_paths_are_relative() {
Test::new()
.justfile("import 'foo/bar.just'")
.write("foo/bar.just", "baz")
.status(EXIT_FAILURE)
.stderr(format!(
"
error: Expected '*', ':', '$', identifier, or '+', but found end of file
βββΆ foo{MAIN_SEPARATOR}bar.just:1:4
β
1 β baz
β ^
",
))
.run();
}
#[test]
#[cfg(not(windows))]
fn file_paths_not_in_subdir_are_absolute() {
Test::new()
.write("foo/justfile", "import '../bar.just'")
.write("bar.just", "baz")
.no_justfile()
.args(["--justfile", "foo/justfile"])
.status(EXIT_FAILURE)
.stderr_regex(
r"error: Expected '\*', ':', '\$', identifier, or '\+', but found end of file
βββΆ /.*/bar.just:1:4
β
1 β baz
β \^
",
)
.run();
}
#[test]
fn redefinition_errors_properly_swap_types() {
Test::new()
.write("foo.just", "foo:")
.justfile("foo:\n echo foo\n\nmod foo 'foo.just'")
.status(EXIT_FAILURE)
.stderr(
"
error: Recipe `foo` defined on line 1 is redefined as a module on line 4
βββΆ justfile:4:5
β
4 β mod foo 'foo.just'
β ^^^
",
)
.run();
}