just/tests/working_directory.rs
Casey Rodarmor 3a287b864a
Housekeeping (#394)
- Upgrade to rust 2018
- Update dependencies
- Use BTree{Map,Set} instead of Map and Set
2019-04-11 15:23:14 -07:00

33 lines
845 B
Rust

use executable_path::executable_path;
use std::{error::Error, fs, process::Command};
use tempdir::TempDir;
/// Test that just runs with the correct working directory when invoked with
/// `--justfile` but not `--working-directory`
#[test]
fn justfile_without_working_directory() -> Result<(), Box<Error>> {
let tmp = TempDir::new("just-integration")?;
let justfile = tmp.path().join("justfile");
let data = tmp.path().join("data");
fs::write(
&justfile,
"foo = `cat data`\ndefault:\n echo {{foo}}\n cat data",
)?;
fs::write(&data, "found it")?;
let output = Command::new(executable_path("just"))
.arg("--justfile")
.arg(&justfile)
.output()?;
if !output.status.success() {
panic!()
}
let stdout = String::from_utf8(output.stdout).unwrap();
assert_eq!(stdout, "found it\nfound it");
Ok(())
}