mod common;
fn repo_path(relative: &str) -> std::path::PathBuf {
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(relative)
}
#[test]
fn the_python_package_and_its_build_files_are_gone() {
for relative in [
"drep",
"tests/unit",
"tests/integration",
"docs/api",
"pyproject.toml",
"uv.lock",
"scripts/install.sh",
] {
assert!(
!repo_path(relative).exists(),
"{relative} is 1.x and should have been deleted with the package"
);
}
}
#[test]
fn no_python_source_survives() {
let root = repo_path(".");
let walker = ignore::WalkBuilder::new(&root)
.hidden(false)
.git_ignore(false)
.git_global(false)
.git_exclude(false)
.parents(false)
.require_git(false)
.filter_entry(|entry| {
if entry.depth() == 0 {
return true;
}
let name = entry.file_name().to_string_lossy().into_owned();
if entry.file_type().is_some_and(|ft| ft.is_dir()) {
return !(drep::files::is_ignored_dir(&name)
|| matches!(name.as_str(), "repos" | "external"));
}
true
})
.build();
let found: Vec<_> = walker
.flatten()
.map(ignore::DirEntry::into_path)
.filter(|path| path.extension().is_some_and(|ext| ext == "py"))
.collect();
assert!(found.is_empty(), "Python source is back: {found:?}");
}
#[test]
fn the_commit_gate_runs_no_python_tooling() {
let config = common::without_comments(".pre-commit-config.yaml");
for needle in ["venv/", "ruff", "pytest", "language: python"] {
assert!(
!config.contains(needle),
".pre-commit-config.yaml still runs {needle}"
);
}
assert!(
config.contains("cargo mutants") || config.contains("mutants-staged.sh"),
"the mutation gate must survive the rewrite"
);
}
#[test]
fn no_workflow_installs_python() {
let workflows = repo_path(".github/workflows");
let entries = std::fs::read_dir(&workflows).expect(".github/workflows must be readable");
let mut checked = 0;
for entry in entries.flatten() {
let path = entry.path();
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{path:?}: {e}"));
for needle in ["setup-python", "pytest", "pip install", "twine"] {
assert!(
!text.contains(needle),
"{path:?} still runs {needle} - 1.x CI outlived the package"
);
}
checked += 1;
}
assert!(checked > 0, "no workflows were checked");
}
#[test]
fn the_readme_installs_the_binary() {
let readme = std::fs::read_to_string(repo_path("README.md")).expect("README.md is readable");
assert!(
!readme.contains("pip install"),
"the README still installs the PyPI package"
);
assert!(
readme.contains("drep-ai-installer.sh") || readme.contains("brew install"),
"the README must install the binary the release workflow ships"
);
}