Prewarm LaTeX format and cache verified project preparation artifacts

This commit is contained in:
gloamxun committed 2026-12-02 18:01:20 +08:00
1 parent fdd327eb01
commit c1742e1c10
10 files changed
+668 -28

No files matched your search

+24
View File
@@ -3707,6 +3707,20 @@ fn format_seed_reuse_restarts_execution_and_checks_live_dependencies() {
assert_eq!(warm.pdf, fresh.pdf);
assert_eq!(warm.source_map.pages, fresh.source_map.pages);
assert_eq!(warm.resources.trace, fresh.resources.trace);
let startup = NativeCompiler::default();
startup.prewarm_format(&p.join("seed.tfx")).unwrap();
let reopened = startup.new_session_sharing_format();
let from_startup = reopened.compile(job.clone()).unwrap();
assert_eq!(
from_startup.format_preparation,
Some(FormatPreparation::Reused)
);
assert_eq!(from_startup.pdf, fresh.pdf);
assert_eq!(from_startup.resources.trace, fresh.resources.trace);
assert!(startup.latest().is_none());
let separate = startup.new_session_sharing_format();
assert!(separate.latest().is_none());
let text = Command::new("pdftotext")
.args(["-raw", "job.pdf", "-"])
.current_dir(&p)
@@ -3727,6 +3741,9 @@ fn format_seed_reuse_restarts_execution_and_checks_live_dependencies() {
.contains("native format source changed")
);
assert!(Arc::ptr_eq(&warm, &compiler.latest().unwrap()));
let error = separate.compile_detailed(job.clone()).err().unwrap();
assert!(error.error.to_string().contains("native format source changed"));
assert!(separate.latest().is_none());
build.output = "replacement.tfx".into();
let replacement = dump_format(build, Cancellation::default()).unwrap();
@@ -3736,6 +3753,13 @@ fn format_seed_reuse_restarts_execution_and_checks_live_dependencies() {
let changed = compiler.compile(job.clone()).unwrap();
assert_eq!(changed.format_preparation, Some(FormatPreparation::Decoded));
assert_ne!(warm.pdf, changed.pdf);
let from_replacement = separate.compile(job.clone()).unwrap();
assert_eq!(
from_replacement.format_preparation,
Some(FormatPreparation::Decoded)
);
assert_eq!(from_replacement.pdf, changed.pdf);
assert!(Arc::ptr_eq(&from_startup, &reopened.latest().unwrap()));
let fresh = NativeCompiler::default().compile(job).unwrap();
assert_eq!(changed.pdf, fresh.pdf);
assert_eq!(changed.source_map.pages, fresh.source_map.pages);