2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2021-04-25 17:02:57 -07:00
|
|
|
|
2021-04-05 21:17:53 -07:00
|
|
|
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"
|
|
|
|
"#,
|
|
|
|
}
|
2021-04-05 21:50:50 -07:00
|
|
|
|
|
|
|
test! {
|
2021-04-25 17:02:57 -07:00
|
|
|
name: evaluate_multiple,
|
2021-04-05 21:50:50 -07:00
|
|
|
justfile: "
|
|
|
|
a := 'x'
|
|
|
|
b := 'y'
|
|
|
|
c := 'z'
|
|
|
|
",
|
2021-04-25 17:02:57 -07:00
|
|
|
args: ("--evaluate", "a", "c"),
|
|
|
|
stderr: "error: `--evaluate` used with unexpected argument: `c`\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
2022-06-25 02:39:06 -07:00
|
|
|
name: evaluate_single_free,
|
2021-04-25 17:02:57 -07:00
|
|
|
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,
|
2021-04-05 21:50:50 -07:00
|
|
|
}
|