just/tests/readme.rs

39 lines
797 B
Rust
Raw Normal View History

use super::*;
#[test]
fn readme() {
2024-05-14 20:07:41 -07:00
let mut justfiles = Vec::new();
let mut current = None;
2022-02-06 16:22:14 -08:00
for line in fs::read_to_string("README.md").unwrap().lines() {
if let Some(mut justfile) = current {
if line == "```" {
justfiles.push(justfile);
current = None;
} else {
justfile += line;
justfile += "\n";
current = Some(justfile);
}
} else if line == "```just" {
current = Some(String::new());
}
}
for justfile in justfiles {
let tmp = tempdir();
let path = tmp.path().join("justfile");
2022-12-15 16:53:21 -08:00
fs::write(path, justfile).unwrap();
let output = Command::new(executable_path("just"))
.current_dir(tmp.path())
.arg("--dump")
.output()
.unwrap();
assert_success(&output);
}
}