Reuse native checkpoints before source length changes
This commit is contained in:
1 parent
465a574124
commit
6acd82dbfa
8 files changed
+222
-4
No files matched your search
@@ -1761,6 +1761,92 @@ fn settled_suffix_carries_a_verified_prefix_into_later_edits() {
|
||||
fs::remove_dir_all(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resized_entry_prefix_reuses_verified_statistics() {
|
||||
let cwd = directory("resized-entry-statistics");
|
||||
let entry = cwd.join("main.tex");
|
||||
let stable = r"
|
||||
\tracingstats=2
|
||||
\shipout\hbox{Cover}\relax
|
||||
\shipout\hbox{Second}\relax
|
||||
\shipout\hbox{Third}\relax
|
||||
";
|
||||
let body = |text| format!(r"{stable}
|
||||
\shipout\hbox{{{text}}}\relax
|
||||
\shipout\hbox{{Last}}\relax
|
||||
\end
|
||||
");
|
||||
let mut project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body("Late"))).unwrap();
|
||||
let mut request = request(&cwd).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let session = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
session.compile(request.clone().with_project(project.clone())).unwrap();
|
||||
|
||||
for (revision, text) in [(2, "Later"), (3, "Now")] {
|
||||
let source = format!("{HEADER}{}", body(text));
|
||||
let after_first_shipout = source.find(r"\shipout\hbox{Second}").unwrap();
|
||||
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_frontier.is_some_and(|frontier| frontier >= after_first_shipout),
|
||||
"{work:?}"
|
||||
);
|
||||
assert!(work.reused_steps > 0, "{work:?}");
|
||||
|
||||
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.sources, full.source_map.sources);
|
||||
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_invalidates_an_executed_file_size_query() {
|
||||
let cwd = directory("resized-entry-file-size");
|
||||
let entry = cwd.join("main.tex");
|
||||
let body = |text| format!(r"
|
||||
\shipout\hbox{{Cover}}\relax
|
||||
\count42=\pdffilesize{{main.tex}}\relax
|
||||
\tracingstats=2
|
||||
\shipout\hbox{{\the\count42}}\relax
|
||||
\shipout\hbox{{{text}}}\relax
|
||||
\end
|
||||
");
|
||||
let project = ProjectSnapshot::new(atomic_definition(&cwd, 1, &body("Late"))).unwrap();
|
||||
let mut request = request(&cwd).observe_generated_initial();
|
||||
request.world = project.configuration();
|
||||
let session = NativeCompiler::default().with_automatic_entry_checkpoints();
|
||||
let initial = session.compile(request.clone().with_project(project.clone())).unwrap();
|
||||
|
||||
let source = format!("{HEADER}{}", body("Later"));
|
||||
let query = source.find(r"\count42=").unwrap();
|
||||
let query_end = query + source[query..].find('\n').unwrap() + 1;
|
||||
assert!(initial.entry_checkpoint_work.captured_frontier.is_some_and(|frontier| frontier > query_end));
|
||||
let bytes = i32::try_from(source.len()).unwrap();
|
||||
let project = project
|
||||
.with_file_edits(2, [(entry, Arc::from(source.into_bytes()))].into())
|
||||
.unwrap();
|
||||
let request = request.with_project(project);
|
||||
let updated = session.compile(request.clone()).unwrap();
|
||||
let full = NativeCompiler::default().compile(request).unwrap();
|
||||
let work = &updated.entry_checkpoint_work;
|
||||
assert!(work.reused_frontier.is_none_or(|frontier| frontier <= query_end), "{work:?}");
|
||||
assert_eq!(updated.execution.execution.state.count(42), bytes);
|
||||
assert_eq!(updated.execution.execution, full.execution.execution);
|
||||
assert_eq!(updated.resources.trace, full.resources.trace);
|
||||
assert_eq!(updated.pdf, full.pdf);
|
||||
fs::remove_dir_all(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settled_suffix_translates_step_counts_and_enforces_the_limit() {
|
||||
let cwd = directory("settled-step-counts");
|
||||
|
||||
Reference in new issue
Block a user