Resume validated native checkpoints inside included sources
This commit is contained in:
1 parent
fb5cb5ada9
commit
84ad682939
8 files changed
+537
-88
No files matched your search
@@ -543,6 +543,87 @@ fn resumed_suffix_reuses_search_for_unchanged_paragraphs() {
|
||||
fs::remove_dir_all(p).unwrap();
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn child_checkpoints_reuse_only_the_validated_physical_prefix() {
|
||||
let root = directory("child-continuation");
|
||||
let leaf = root.join("leaf.tex");
|
||||
let parent = root.join("parent.tex");
|
||||
let main = r"\shipout\hbox{Main}
|
||||
\input parent.tex
|
||||
\shipout\hbox{Final}
|
||||
\end
|
||||
";
|
||||
let original = r"\def\prefix{Original}
|
||||
\shipout\hbox{\prefix}
|
||||
\def\label{Measured at 100 points}
|
||||
\shipout\hbox{\label}
|
||||
\relax
|
||||
";
|
||||
let make_project = |main: &str| {
|
||||
let mut definition = atomic_definition(&root, 1, main);
|
||||
definition.files.extend([
|
||||
(parent.clone(), Arc::from(br"\relax
|
||||
\input leaf.tex
|
||||
\relax
|
||||
".as_slice())),
|
||||
(leaf.clone(), Arc::from(original.as_bytes())),
|
||||
]);
|
||||
ProjectSnapshot::new(definition).unwrap()
|
||||
};
|
||||
let mut project = make_project(main);
|
||||
let compiler = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
let mut request = request(&root).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let mut prior = compiler.compile(request.clone().with_project(project.clone())).unwrap();
|
||||
assert_eq!(prior.pages.len(), 4);
|
||||
|
||||
for (revision, child, expected_pages, reuse_leaf) in [
|
||||
(2, original.replace("100 points", "200 points"), vec![2], true),
|
||||
(3, original.replace("100 points", "3000 points"), vec![2, 3], true),
|
||||
(4, original.replace("Original", "Different").replace("100 points", "3000 points"), vec![1], false),
|
||||
] {
|
||||
let mut edits = BTreeMap::from([(leaf.clone(), Arc::from(child.into_bytes()))]);
|
||||
if revision == 3 {
|
||||
let updated = format!("{HEADER}{}", main.replace("Final", "Close"));
|
||||
edits.insert(root.join("main.tex"), Arc::from(updated.into_bytes()));
|
||||
}
|
||||
project = project.with_file_edits(revision, edits).unwrap();
|
||||
let job = request.clone().with_project(project.clone());
|
||||
let after = compiler.compile(job.clone()).unwrap();
|
||||
let full = NativeCompiler::default().compile(job).unwrap();
|
||||
let work = &after.entry_checkpoint_work;
|
||||
assert_eq!(work.reused_source.as_deref() == Some(leaf.as_path()), reuse_leaf, "{work:?}");
|
||||
if reuse_leaf {
|
||||
assert!(work.reused_frontier.unwrap() >= original.find(r"\shipout\hbox{\prefix}").unwrap(), "{work:?}");
|
||||
}
|
||||
assert!(after.execution.execution == full.execution.execution);
|
||||
assert_eq!(after.execution.execution_resources, full.execution.execution_resources);
|
||||
assert_eq!(after.source_map.sources, full.source_map.sources);
|
||||
assert_eq!(after.source_map.pages, full.source_map.pages);
|
||||
assert_eq!(after.pdf, full.pdf);
|
||||
assert_eq!(after.preview_since(None).unwrap().pages, full.preview_since(None).unwrap().pages);
|
||||
assert_eq!(after.preview_since(Some(prior.revision())).unwrap().pages
|
||||
.into_iter().map(|page| page.index).collect::<Vec<_>>(), expected_pages);
|
||||
prior = after;
|
||||
}
|
||||
|
||||
// A whole-file consumer makes changes to any byte observable before input.
|
||||
let probed = make_project(&format!(r"\count0=\pdffilesize{{leaf.tex}}\relax
|
||||
{main}"));
|
||||
let guarded = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
guarded.compile(request.clone().with_project(probed.clone())).unwrap();
|
||||
let changed = original.replace("100 points", "3000 points");
|
||||
let probed = probed.with_file_edits(2, [(leaf.clone(), Arc::from(changed.into_bytes()))].into()).unwrap();
|
||||
let job = request.with_project(probed);
|
||||
let after = guarded.compile(job.clone()).unwrap();
|
||||
let full = NativeCompiler::default().compile(job).unwrap();
|
||||
assert_ne!(after.entry_checkpoint_work.reused_source.as_deref(), Some(leaf.as_path()));
|
||||
assert!(after.execution.execution == full.execution.execution);
|
||||
assert_eq!(after.pdf, full.pdf);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unicode_math_code_edit_updates_the_page_that_reads_the_table() {
|
||||
let p = directory("unicode-math-code");
|
||||
|
||||
Reference in new issue
Block a user