-
Notifications
You must be signed in to change notification settings - Fork 499
/
evaluate.rs
105 lines (96 loc) · 1.61 KB
/
evaluate.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
use super::*;
test! {
name: evaluate,
justfile: r#"
foo := "a\t"
hello := "c"
bar := "b\t"
ab := foo + bar + hello
wut:
touch /this/is/not/a/file
"#,
args: ("--evaluate"),
stdout: r#"ab := "a b c"
bar := "b "
foo := "a "
hello := "c"
"#,
}
test! {
name: evaluate_empty,
justfile: "
a := 'foo'
",
args: ("--evaluate"),
stdout: r#"
a := "foo"
"#,
}
test! {
name: evaluate_multiple,
justfile: "
a := 'x'
b := 'y'
c := 'z'
",
args: ("--evaluate", "a", "c"),
stderr: "error: `--evaluate` used with unexpected argument: `c`\n",
status: EXIT_FAILURE,
}
test! {
name: evaluate_single_free,
justfile: "
a := 'x'
b := 'y'
c := 'z'
",
args: ("--evaluate", "b"),
stdout: "y",
}
test! {
name: evaluate_no_suggestion,
justfile: "
abc := 'x'
",
args: ("--evaluate", "aby"),
stderr: "
error: Justfile does not contain variable `aby`.
Did you mean `abc`?
",
status: EXIT_FAILURE,
}
test! {
name: evaluate_suggestion,
justfile: "
hello := 'x'
",
args: ("--evaluate", "goodbye"),
stderr: "
error: Justfile does not contain variable `goodbye`.
",
status: EXIT_FAILURE,
}
test! {
name: evaluate_private,
justfile: "
[private]
foo := 'one'
bar := 'two'
_baz := 'three'
",
args: ("--evaluate"),
stdout: "bar := \"two\"\n",
status: EXIT_SUCCESS,
}
test! {
name: evaluate_single_private,
justfile: "
[private]
foo := 'one'
bar := 'two'
_baz := 'three'
",
args: ("--evaluate", "foo"),
stdout: "one",
status: EXIT_SUCCESS,
}