use std::path::PathBuf;
use std::process::Command;
fn fixture(name: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/fixtures/integration_lint/python")
.join(name)
}
fn lint_exit(codebase: &str) -> i32 {
Command::new(env!("CARGO_BIN_EXE_testing-conventions"))
.args(["integration", "lint", "--language", "python"])
.arg(fixture(codebase))
.status()
.expect("the built binary should run")
.code()
.expect("the process should exit with a code")
}
fn lint_exit_with_config(codebase: &str, config: &str) -> i32 {
Command::new(env!("CARGO_BIN_EXE_testing-conventions"))
.args(["integration", "lint", "--language", "python", "--config"])
.arg(fixture(config))
.arg(fixture(codebase))
.status()
.expect("the built binary should run")
.code()
.expect("the process should exit with a code")
}
#[test]
fn monkeypatch_red_exits_nonzero() {
assert_eq!(lint_exit("monkeypatch/red"), 1);
}
#[test]
fn monkeypatch_clean_exits_zero() {
assert_eq!(lint_exit("monkeypatch/clean"), 0);
}
#[test]
fn inline_patch_red_exits_nonzero() {
assert_eq!(lint_exit("inline_patch/red"), 1);
}
#[test]
fn inline_patch_clean_exits_zero() {
assert_eq!(lint_exit("inline_patch/clean"), 0);
}
#[test]
fn environ_red_exits_nonzero() {
assert_eq!(lint_exit("environ/red"), 1);
}
#[test]
fn environ_clean_exits_zero() {
assert_eq!(lint_exit("environ/clean"), 0);
}
#[test]
fn constant_patch_red_exits_nonzero() {
assert_eq!(lint_exit("constant_patch/red"), 1);
}
#[test]
fn constant_patch_waived_exits_zero() {
assert_eq!(
lint_exit_with_config(
"constant_patch/waived",
"constant_patch/waived/testing-conventions.toml"
),
0
);
}