Share native checkpoint command bindings and output probes
This commit is contained in:
1 parent
8aa079ec25
commit
373204a8d8
4 files changed
+167
-50
No files matched your search
+44
-7
@@ -328,12 +328,10 @@ impl Files {
|
||||
|| existing_log.as_ref() == Some(&resource.path)
|
||||
|| existing_output.as_ref() == Some(&resource.path)
|
||||
})
|
||||
|| preparation.aliases_any(
|
||||
&log_path,
|
||||
|| preparation.either_aliases_any(
|
||||
[&log_path, &pdf],
|
||||
world.trace().reads.iter().map(|r| r.path.as_path()),
|
||||
)
|
||||
|| preparation
|
||||
.aliases_any(&pdf, world.trace().reads.iter().map(|r| r.path.as_path()))
|
||||
|| preparation.same_file(source, &log_path)
|
||||
|| preparation.same_file(&pdf, &log_path)
|
||||
{
|
||||
@@ -368,9 +366,7 @@ impl Files {
|
||||
protected.extend(project.immutable_paths().map(Path::to_path_buf));
|
||||
protected.sort();
|
||||
protected.dedup();
|
||||
if preparation.aliases_any(&pdf, project.immutable_paths())
|
||||
|| preparation.aliases_any(&log_path, project.immutable_paths())
|
||||
{
|
||||
if preparation.either_aliases_any([&pdf, &log_path], project.immutable_paths()) {
|
||||
return Err("native output would overwrite an atomic project input".into());
|
||||
}
|
||||
}
|
||||
@@ -2864,6 +2860,47 @@ mod generated_file_tests {
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn paired_alias_scan_reads_an_input_once_and_rechecks_either_destination() {
|
||||
use crate::native_host::HostObservation;
|
||||
use std::cell::Cell;
|
||||
|
||||
let root = root();
|
||||
let pdf = root.join("job.pdf");
|
||||
let log = root.join("job.log");
|
||||
let input = root.join("main.tex");
|
||||
let replacement = root.join("pending-link");
|
||||
for output in [&pdf, &log] {
|
||||
fs::write(output, b"independent destination").unwrap();
|
||||
}
|
||||
|
||||
let mut preparation = HostPreparation::default();
|
||||
assert!(!preparation.either_aliases_any([&pdf, &log], [input.as_path()].into_iter()));
|
||||
let input_reads = preparation.observations.iter().filter(|observation| {
|
||||
matches!(observation, HostObservation::Metadata { path, .. } if path == &input)
|
||||
});
|
||||
assert_eq!(input_reads.count(), 1);
|
||||
|
||||
for output in [&pdf, &log] {
|
||||
fs::hard_link(&input, &replacement).unwrap();
|
||||
let switched = Cell::new(false);
|
||||
let candidates = [input.as_path()].into_iter().inspect(|_| {
|
||||
if !switched.replace(true) {
|
||||
fs::rename(&replacement, output).unwrap();
|
||||
}
|
||||
});
|
||||
let mut preparation = HostPreparation::default();
|
||||
assert!(preparation.either_aliases_any([&pdf, &log], candidates));
|
||||
assert!(preparation.observations.iter().any(|observation| {
|
||||
matches!(observation, HostObservation::Alias { right, same: true, .. } if right == output)
|
||||
}));
|
||||
fs::remove_file(output).unwrap();
|
||||
fs::write(output, b"independent destination").unwrap();
|
||||
}
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn preparation_alias_rejection_records_actual_hardlink_identity() {
|
||||
|
||||
Reference in new issue
Block a user