Skip to content

Commit

Permalink
Add tests for variables in module source paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Feb 26, 2024
1 parent bc87ad0 commit ac79807
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion tests/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn submodule_shebang_recipes_run_in_submodule_directory() {

#[cfg(not(windows))]
#[test]
fn module_paths_beginning_with_tilde_are_expanded_to_homdir() {
fn module_paths_beginning_with_tilde_are_expanded_to_homedir() {
Test::new()
.write("foobar/mod.just", "foo:\n @echo FOOBAR")
.justfile(
Expand All @@ -685,6 +685,47 @@ fn module_paths_beginning_with_tilde_are_expanded_to_homdir() {
.run();
}

#[test]
fn module_paths_with_variables_are_expanded() {
Test::new()
.write("foobar/mod.just", "foo:\n @echo FOOBAR")
.justfile(
"
mod foo '$FOO/mod.just'
",
)
.test_round_trip(false)
.arg("--unstable")
.arg("foo")
.arg("foo")
.stdout("FOOBAR\n")
.env("FOO", "foobar")
.run();
}

#[test]
fn unresolved_variable_in_module_error() {
Test::new()
.justfile(
"
mod foo '$FOO/mod.just'
",
)
.test_round_trip(false)
.arg("--unstable")
.status(EXIT_FAILURE)
.stderr(
"
error: Source path for foo contains unresolved variable FOO.
——▶ justfile:1:5
1 │ mod foo '$FOO/mod.just'
│ ^^^
",
)
.run();
}

#[test]
fn module_recipe_list_alignment_ignores_private_recipes() {
Test::new()
Expand Down

0 comments on commit ac79807

Please sign in to comment.