Skip to content

Commit

Permalink
Test error messages when both workdir and shell are unusable
Browse files Browse the repository at this point in the history
  • Loading branch information
artm committed Sep 1, 2024
1 parent 79e1efa commit 1d9a50d
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/working_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,63 @@ fn working_directory_is_not_a_directory_produces_clear_message() {
.stderr_regex(".*Failed to run recipe `default`:\n Failed to run shell `bash`:\n .*\n Failed to set working directory to `.*/unusable`.*")
.run();
}

#[test]
fn missing_working_directory_and_missing_shell_produces_clear_message() {
Test::new()
.justfile(
"
set working-directory := 'missing'
default:
pwd
",
)
.shell(false)
.args(["--shell", "NOT_A_REAL_SHELL"])
.status(1)
.stderr_regex(".*Failed to run recipe `default`:\n Failed to run shell `NOT_A_REAL_SHELL`:\n .*\n Failed to set working directory to `.*/missing`.*")
.run();
}

#[test]
#[cfg(unix)]
fn unusable_working_directory_and_missing_shell_produces_clear_message() {
use {fs::Permissions, std::os::unix::fs::PermissionsExt};
Test::new()
.justfile(
"
set working-directory := 'unusable'
default:
pwd
",
)
.tree(tree! {
unusable: {}
})
.shell(false)
.args(["--shell", "NOT_A_REAL_SHELL"])
.chmod("unusable", Permissions::from_mode(0o000))
.status(1)
.stderr_regex(".*Failed to run recipe `default`:\n Failed to run shell `NOT_A_REAL_SHELL`:\n .*\n Failed to set working directory to `.*/unusable`.*")
.run();
}

#[test]
fn working_directory_is_not_a_directory_and_missing_shell_produces_clear_message() {
Test::new()
.justfile(
"
set working-directory := 'unusable'
default:
pwd
",
)
.tree(tree! {
unusable: "is not a directory"
})
.shell(false)
.args(["--shell", "NOT_A_REAL_SHELL"])
.status(1)
.stderr_regex(".*Failed to run recipe `default`:\n Failed to run shell `NOT_A_REAL_SHELL`:\n .*\n Failed to set working directory to `.*/unusable`.*")
.run();
}

0 comments on commit 1d9a50d

Please sign in to comment.