34 lines
715 B
Rust
34 lines
715 B
Rust
|
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");
|
||
|
}
|
||
|
}
|