Prove suffix reuse across unequal retained histories
This commit is contained in:
1 parent
f78aff25c5
commit
1ff049737f
9 files changed
+781
-153
No files matched your search
@@ -1763,29 +1763,29 @@ fn settled_suffix_carries_a_verified_prefix_into_later_edits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settled_suffix_keeps_new_prefix_reads_but_rejects_missing_reads() {
|
||||
fn settled_suffix_distinguishes_removed_prefix_reads_from_repeated_suffix_reads() {
|
||||
use texrra_tex_core::execution::Dependency;
|
||||
|
||||
let cwd = directory("settled-prefix-dependencies");
|
||||
let entry = cwd.join("main.tex");
|
||||
let body = |ignored| format!(r"
|
||||
let body = |ignored, repeat| format!(r"
|
||||
\catcode64=9 \catcode63=9
|
||||
?\relax
|
||||
\shipout\hbox{{Cover}}\relax
|
||||
{ignored}\relax
|
||||
\shipout\hbox{{Checkpoint}}\relax
|
||||
\shipout\hbox{{Suffix}}\relax
|
||||
{repeat}\relax\shipout\hbox{{Suffix}}\relax
|
||||
\endinput\shipout\hbox{{Final}}\relax\end
|
||||
");
|
||||
for (before, after, reuse) in [('?', '@', true), ('@', '?', false)] {
|
||||
let project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body(before))).unwrap();
|
||||
for (before, after, repeat) in [('?', '@', '?'), ('@', '?', '?'), ('@', '?', '@')] {
|
||||
let project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body(before, repeat))).unwrap();
|
||||
let mut request = request(&cwd).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let session = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
let donor = session.compile(request.clone().with_project(project.clone())).unwrap();
|
||||
let new_read = Dependency::CatCode('@');
|
||||
assert_eq!(donor.execution.execution.reads.contains(&new_read), before == '@');
|
||||
let source = format!("{HEADER}{}", body(after));
|
||||
assert_eq!(donor.execution.execution.reads.contains(&new_read), before == '@' || repeat == '@');
|
||||
let source = format!("{HEADER}{}", body(after, repeat));
|
||||
let project = project.with_file_edits(
|
||||
2, [(entry.clone(), Arc::from(source.into_bytes()))].into(),
|
||||
).unwrap();
|
||||
@@ -1793,8 +1793,8 @@ fn settled_suffix_keeps_new_prefix_reads_but_rejects_missing_reads() {
|
||||
let updated = session.compile(input.clone()).unwrap();
|
||||
let work = &updated.entry_checkpoint_work;
|
||||
assert!(!work.reused_completion, "{work:?}");
|
||||
assert_eq!(work.reused_suffix_steps > 0, reuse, "{work:?}");
|
||||
assert_eq!(updated.execution.execution.reads.contains(&new_read), after == '@');
|
||||
assert!(work.reused_suffix_steps > 0, "{work:?}");
|
||||
assert_eq!(updated.execution.execution.reads.contains(&new_read), after == '@' || repeat == '@');
|
||||
let log = fs::read(cwd.join("job.log")).unwrap();
|
||||
let full = NativeCompiler::default().compile(input).unwrap();
|
||||
assert_eq!(updated.execution.execution, full.execution.execution);
|
||||
@@ -1862,6 +1862,62 @@ fn settled_suffix_translates_cumulative_box_charges_in_both_directions() {
|
||||
fs::remove_dir_all(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settled_suffix_translates_final_retained_statistics_for_unequal_histories() {
|
||||
use texrra_tex_core::execution::{Event, StatisticsPhase};
|
||||
|
||||
let cwd = directory("settled-retained-history");
|
||||
let entry = cwd.join("main.tex");
|
||||
let body = |stats, text| format!(r"
|
||||
\tracingstats={stats}
|
||||
\shipout\hbox{{Cover with x}}\relax
|
||||
\shipout\hbox{{{text}}}\relax
|
||||
\shipout\hbox{{Suffix}}\relax
|
||||
\endinput\shipout\hbox{{Final}}\relax\end
|
||||
");
|
||||
let retained = |document: &CompiledDocument| {
|
||||
let Some(Event::Statistics(report)) = document.execution.execution.events.last() else {
|
||||
panic!("missing final resource report");
|
||||
};
|
||||
let StatisticsPhase::End { usage, .. } = &report.phase else {
|
||||
panic!("expected final resource report");
|
||||
};
|
||||
(usage.retained_events, usage.retained_material.horizontal_nodes)
|
||||
};
|
||||
|
||||
for (stats, before, after, reuse) in [
|
||||
(1, "x", "xxxxxxx", true),
|
||||
(1, "xxxxxxx", "x", true),
|
||||
(2, "x", "xxxxxxx", false),
|
||||
] {
|
||||
let project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body(stats, before))).unwrap();
|
||||
let mut request = request(&cwd).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let session = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
let donor = session.compile(request.clone().with_project(project.clone())).unwrap();
|
||||
let source = format!("{HEADER}{}", body(stats, after));
|
||||
let project = project.with_file_edits(
|
||||
2, [(entry.clone(), Arc::from(source.into_bytes()))].into(),
|
||||
).unwrap();
|
||||
let input = request.with_project(project);
|
||||
let updated = session.compile(input.clone()).unwrap();
|
||||
let work = &updated.entry_checkpoint_work;
|
||||
assert!(!work.reused_completion, "{work:?}");
|
||||
if reuse {
|
||||
assert!(work.reused_suffix_steps > 0, "{work:?}");
|
||||
}
|
||||
assert_ne!(retained(&updated), retained(&donor));
|
||||
let log = fs::read(cwd.join("job.log")).unwrap();
|
||||
let full = NativeCompiler::default().compile(input).unwrap();
|
||||
assert_eq!(updated.execution.execution, full.execution.execution);
|
||||
assert_eq!(updated.resources.trace, full.resources.trace);
|
||||
assert_eq!(updated.pdf, full.pdf);
|
||||
assert_eq!(updated.source_map.pages, full.source_map.pages);
|
||||
assert_eq!(log, fs::read(cwd.join("job.log")).unwrap());
|
||||
}
|
||||
fs::remove_dir_all(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resized_entry_prefix_reuses_verified_statistics() {
|
||||
let cwd = directory("resized-entry-statistics");
|
||||
|
||||
Reference in new issue
Block a user