2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2021-07-26 01:26:06 -07:00
|
|
|
|
|
|
|
test! {
|
|
|
|
name: show,
|
|
|
|
justfile: r#"hello := "foo"
|
|
|
|
bar := hello + hello
|
|
|
|
recipe:
|
|
|
|
echo {{hello + "bar" + bar}}"#,
|
|
|
|
args: ("--show", "recipe"),
|
|
|
|
stdout: r#"
|
|
|
|
recipe:
|
|
|
|
echo {{ hello + "bar" + bar }}
|
|
|
|
"#,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: alias_show,
|
|
|
|
justfile: "foo:\n bar\nalias f := foo",
|
|
|
|
args: ("--show", "f"),
|
|
|
|
stdout: "
|
|
|
|
alias f := foo
|
|
|
|
foo:
|
|
|
|
bar
|
|
|
|
",
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: alias_show_missing_target,
|
|
|
|
justfile: "alias f := foo",
|
|
|
|
args: ("--show", "f"),
|
|
|
|
stderr: "
|
|
|
|
error: Alias `f` has an unknown target `foo`
|
2023-12-29 13:25:30 -08:00
|
|
|
——▶ justfile:1:7
|
|
|
|
│
|
|
|
|
1 │ alias f := foo
|
|
|
|
│ ^
|
2021-07-26 01:26:06 -07:00
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: show_suggestion,
|
|
|
|
justfile: r#"
|
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
|
|
|
args: ("--show", "hell"),
|
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `hell`.\nDid you mean `hello`?\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: show_alias_suggestion,
|
|
|
|
justfile: r#"
|
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
alias foo := hello
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
|
|
|
args: ("--show", "fo"),
|
|
|
|
stdout: "",
|
|
|
|
stderr: "
|
|
|
|
error: Justfile does not contain recipe `fo`.
|
|
|
|
Did you mean `foo`, an alias for `hello`?
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: show_no_suggestion,
|
|
|
|
justfile: r#"
|
|
|
|
helloooooo a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
|
|
|
args: ("--show", "hell"),
|
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `hell`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
test! {
|
|
|
|
name: show_no_alias_suggestion,
|
|
|
|
justfile: r#"
|
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
alias foo := hello
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
|
|
|
args: ("--show", "fooooooo"),
|
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `fooooooo`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2024-05-29 18:41:37 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_recipe_at_path() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "bar:\n @echo MODULE")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.test_round_trip(false)
|
|
|
|
.args(["--unstable", "--show", "foo::bar"])
|
|
|
|
.stdout("bar:\n @echo MODULE\n")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_invalid_path() {
|
|
|
|
Test::new()
|
|
|
|
.args(["--show", "$hello"])
|
|
|
|
.stderr("error: Invalid module path `$hello`\n")
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
2024-06-08 18:01:24 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn show_space_separated_path() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "bar:\n @echo MODULE")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.test_round_trip(false)
|
|
|
|
.args(["--unstable", "--show", "foo bar"])
|
|
|
|
.stdout("bar:\n @echo MODULE\n")
|
|
|
|
.run();
|
|
|
|
}
|