2021-07-04 00:26:59 +03:00
|
|
|
use crate::common::*;
|
2019-11-20 10:07:44 +03:00
|
|
|
|
|
|
|
const EXPECTED: &str = "default:\n\techo 'Hello, world!'\n";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn current_dir() {
|
|
|
|
let tmp = tempdir();
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn exists() {
|
|
|
|
let tmp = tempdir();
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(!output.status.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn invocation_directory() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:07:44 +03:00
|
|
|
".git": {},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-11-20 10:35:29 +03:00
|
|
|
#[test]
|
|
|
|
fn parent_dir() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:35:29 +03:00
|
|
|
".git": {},
|
|
|
|
sub: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path().join("sub"))
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-11-20 10:07:44 +03:00
|
|
|
#[test]
|
|
|
|
fn alternate_marker() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:07:44 +03:00
|
|
|
"_darcs": {},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn search_directory() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:07:44 +03:00
|
|
|
sub: {
|
|
|
|
".git": {},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--init")
|
|
|
|
.arg("sub/")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("sub/justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn justfile() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:07:44 +03:00
|
|
|
sub: {
|
|
|
|
".git": {},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path().join("sub"))
|
|
|
|
.arg("--init")
|
|
|
|
.arg("--justfile")
|
|
|
|
.arg(tmp.path().join("justfile"))
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn justfile_and_working_directory() {
|
2021-07-04 00:26:59 +03:00
|
|
|
let tmp = temptree! {
|
2019-11-20 10:07:44 +03:00
|
|
|
sub: {
|
|
|
|
".git": {},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = Command::new(executable_path("just"))
|
|
|
|
.current_dir(tmp.path().join("sub"))
|
|
|
|
.arg("--init")
|
|
|
|
.arg("--justfile")
|
|
|
|
.arg(tmp.path().join("justfile"))
|
|
|
|
.arg("--working-directory")
|
|
|
|
.arg("/")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fs::read_to_string(tmp.path().join("justfile")).unwrap(),
|
|
|
|
EXPECTED
|
|
|
|
);
|
|
|
|
}
|