Give the derivation test a directory of its own
Soul F4. The derivation test wrote its stale copies into one shared temp directory and cleared it first with `remove_dir_all(...).ok()`. The clear was best-effort and unverified: a held handle refuses the delete on Windows, `.ok()` swallows the refusal, and a previous run's file survives in a directory whose path the failure message invites the reader to copy from. The mutation suite runs M8 and M11 against this test and never cleans up after them, so the leftovers it would hide are mutated schemas no committed type produces. The directory is now per-run, named by process id and nanosecond, so there is no sharing to defend and the clear and its `.ok()` are gone rather than hardened. It is still created only when something is stale, so a passing run leaves nothing behind. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
b6f6e8023c
commit
80db5db6c0
1 changed files with 13 additions and 6 deletions
|
|
@ -1293,12 +1293,19 @@ mod tests {
|
|||
fn pipeline_published_schemas_match_derivation() -> Result<()> {
|
||||
let published = Path::new(env!("CARGO_MANIFEST_DIR")).join("../schemas/cultnet");
|
||||
let index: serde_json::Value = serde_json::from_slice(&std::fs::read(published.join("index.json"))?)?;
|
||||
let derived_dir = std::env::temp_dir().join("epiphany-pipeline-schemas");
|
||||
// Emptied first, so what is left in it is what this run derived. A
|
||||
// previous run's leftovers -- a mutation run's especially -- are not
|
||||
// this derivation, and copying one of those into `schemas/cultnet`
|
||||
// publishes a schema no Rust type produces.
|
||||
std::fs::remove_dir_all(&derived_dir).ok();
|
||||
// A directory this run alone writes, so everything in it is what this
|
||||
// run derived. A previous run's leftovers -- a mutation run's
|
||||
// especially, since those deliberately derive schemas no committed type
|
||||
// produces -- are not this derivation, and copying one of those into
|
||||
// `schemas/cultnet` publishes a schema no Rust type produces. A shared
|
||||
// directory cleared first would have to defend that clear against a
|
||||
// held handle; an unshared one has nothing to defend. The directory is
|
||||
// only created when something is stale, so a passing run leaves none.
|
||||
let derived_dir = std::env::temp_dir().join(format!(
|
||||
"epiphany-pipeline-schemas-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)?.as_nanos()
|
||||
));
|
||||
let mut stale = Vec::new();
|
||||
for kind in PipelineKind::ALL {
|
||||
let file = format!("{}.schema.json", kind.type_id());
|
||||
|
|
|
|||
Reference in a new issue