aefdcea7d0
- Instead of changing the current directory with `env::set_current_dir` to be implicitly inherited by subprocesses, we now use `Command::current_dir` to set it explicitly. This feels much better, since we aren't dependent on the implicit state of the process's current directory. - Subcommand execution is much improved. - Added a ton of tests for config parsing, config execution, working dir, and search dir. - Error messages are improved. Many more will be colored. - The Config is now onwed, instead of borrowing from the arguments and the `clap::ArgMatches` object. This is a huge ergonomic improvement, especially in tests, and I don't think anyone will notice. - `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order, matching git, which I think is what most people will expect. - Added a cute `tmptree!{}` macro, for creating temporary directories populated with directories and files for tests. - Admitted that grammer is LL(k) and I don't know what `k` is.
41 lines
851 B
Rust
41 lines
851 B
Rust
use std::{process::Command, str};
|
|
|
|
use executable_path::executable_path;
|
|
|
|
use test_utilities::{assert_stdout, tmptree};
|
|
|
|
const JUSTFILE: &str = "
|
|
expression := `EXPRESSION`
|
|
|
|
recipe default=`DEFAULT`:
|
|
{{expression}}
|
|
{{default}}
|
|
RECIPE
|
|
";
|
|
|
|
/// Test that --shell correctly sets the shell
|
|
#[cfg(unix)]
|
|
#[test]
|
|
fn shell() {
|
|
let tmp = tmptree! {
|
|
justfile: JUSTFILE,
|
|
shell: "#!/usr/bin/env bash\necho \"$@\"",
|
|
};
|
|
|
|
let shell = tmp.path().join("shell");
|
|
|
|
let permissions = std::os::unix::fs::PermissionsExt::from_mode(0o700);
|
|
std::fs::set_permissions(&shell, permissions).unwrap();
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
.current_dir(tmp.path())
|
|
.arg("--shell")
|
|
.arg(shell)
|
|
.output()
|
|
.unwrap();
|
|
|
|
let stdout = "-cu -cu EXPRESSION\n-cu -cu DEFAULT\n-cu RECIPE\n";
|
|
|
|
assert_stdout(&output, stdout);
|
|
}
|