Skip to content

Commit

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

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

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

#[test]
fn unresolved_variable_in_import_error() {
Test::new()
.justfile(
"
import '$FOO/import.justfile'
a:
@echo A
",
)
.test_round_trip(false)
.arg("a")
.status(EXIT_FAILURE)
.stderr(
"
error: Path to file contains unresolved variable FOO.
——▶ justfile:1:8
1 │ import '$FOO/import.justfile'
│ ^^^^^^^^^^^^^^^^^^^^^^
",
)
.run();
}

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

0 comments on commit bc87ad0

Please sign in to comment.