oysh/crates/oyster/tests/it/tidy.rs

34 lines
715 B
Rust
Raw Normal View History

2022-07-14 22:26:57 +00:00
use std::{
path::PathBuf,
process::{Command, Stdio},
};
fn project_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.to_owned()
}
#[test]
fn code_is_formatted() {
let output = Command::new("cargo")
.args(["fmt", "--", "--check"])
.current_dir(project_root())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.unwrap();
if !output.status.success() {
Command::new("cargo")
.arg("fmt")
.current_dir(project_root())
.output()
.unwrap();
panic!("code wasn't formatted");
}
}