pub mod config;
pub mod error;
pub mod path;
pub mod version;
pub use error::{Error, Result};
pub use path::{normalize, normalize_for_key, normalize_msys_path, NormalizedPath};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cargo_and_pyproject_versions_match() {
let workspace_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("crates/ dir")
.parent()
.expect("workspace root");
let pyproject = std::fs::read_to_string(workspace_root.join("pyproject.toml"))
.expect("failed to read pyproject.toml");
let pyproject_version = pyproject
.lines()
.find_map(|line| {
let line = line.trim();
if line.starts_with("version") {
let (_, val) = line.split_once('=')?;
Some(val.trim().trim_matches('"').to_string())
} else {
None
}
})
.expect("pyproject.toml missing `version` field");
assert_eq!(
VERSION, pyproject_version,
"\n\nVersion mismatch!\n\
\n Cargo.toml (workspace): {VERSION}\
\n pyproject.toml: {pyproject_version}\
\n\nThese must match. The Cargo workspace version is what `zccache --version`\n\
prints, and the pyproject.toml version is what gets published to PyPI.\n\
Update both files to the same version.\n"
);
}
}