Retain verified suffix bases across consecutive page edits
This commit is contained in:
1 parent
fe86163767
commit
a5dba52acb
3 files changed
+104
-16
No files matched your search
@@ -1649,6 +1649,59 @@ fn checkpoint_tracks_consumed_stream_bytes_and_eof_across_page_edits() {
|
||||
fs::remove_dir_all(p).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consecutive_edits_reuse_later_settled_suffixes() {
|
||||
let cwd = directory("consecutive-settled-suffixes");
|
||||
let entry = cwd.join("main.tex");
|
||||
let body = |second, third| format!(r"
|
||||
\tracingstats=1
|
||||
\shipout\hbox{{Cover ABCXYZ}}
|
||||
\setbox3=\hbox{{{second}}}
|
||||
\shipout\box3
|
||||
\relax
|
||||
\setbox3=\hbox{{{third}}}
|
||||
\shipout\box3
|
||||
\relax
|
||||
\shipout\hbox{{Unchanged}}
|
||||
\end
|
||||
");
|
||||
let mut project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body('A', 'X'))).unwrap();
|
||||
let mut request = request(&cwd).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let session = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
let mut previous = session
|
||||
.compile(request.clone().with_project(project.clone()))
|
||||
.unwrap();
|
||||
|
||||
for (revision, second, third, expected_page) in [
|
||||
(2, 'B', 'X', 1),
|
||||
(3, 'C', 'X', 1),
|
||||
(4, 'C', 'Y', 2),
|
||||
] {
|
||||
let source = format!("{HEADER}{}", body(second, third));
|
||||
project = project
|
||||
.with_file_edits(revision, [(entry.clone(), Arc::from(source.into_bytes()))].into())
|
||||
.unwrap();
|
||||
let input = request.clone().with_project(project.clone());
|
||||
let updated = session.compile(input.clone()).unwrap();
|
||||
let work = &updated.entry_checkpoint_work;
|
||||
assert!(work.reused_suffix_steps > 0, "revision {revision}: {work:?}");
|
||||
let preview = updated.preview_since(Some(previous.revision())).unwrap();
|
||||
let changed: Vec<_> = preview.pages.iter().map(|page| page.index).collect();
|
||||
assert_eq!(changed, [expected_page]);
|
||||
|
||||
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.pages, full.pages);
|
||||
assert_eq!(updated.source_map.sources, full.source_map.sources);
|
||||
assert_eq!(updated.source_map.pages, full.source_map.pages);
|
||||
previous = updated;
|
||||
}
|
||||
fs::remove_dir_all(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settled_suffix_replays_with_the_edited_prefix_and_discards_a_rejected_draft() {
|
||||
let cwd = directory("settled-suffix");
|
||||
|
||||
Reference in new issue
Block a user