Reduce Windows desktop format, opening and edit latency

This commit is contained in:
gloamxun committed 2026-12-03 00:02:37 +08:00
1 parent 4655f8a3c9
commit 830292b9b6
15 files changed
+1006 -167

No files matched your search

+74
View File
@@ -3766,6 +3766,80 @@ fn format_seed_reuse_restarts_execution_and_checks_live_dependencies() {
fs::remove_dir_all(p).unwrap();
}
#[test]
fn bundled_format_rebinds_captured_tex_and_stream_data_after_move() {
let root = directory("bundled-format").canonicalize().unwrap();
let staging = root.join("staging");
let installed = root.join("installed");
let project = root.join("project");
let mode = staging.join("formats/pdflatex");
let texmf = staging.join("texmf");
for directory in [&mode, &texmf, &project] {
fs::create_dir_all(directory).unwrap();
}
let seed = texmf.join("seed.tex");
fs::write(
&seed,
br"\catcode123=1 \catcode125=2 \pdfoutput=1
\input layout.tex
\openin3=texsys.aux \read3 to\storedwidth \closein3
\dump
",
)
.unwrap();
fs::write(
texmf.join("layout.tex"),
br"\def\savedrule{\vrule width\storedwidth height4pt depth0pt}",
)
.unwrap();
fs::write(mode.join("texsys.aux"), b"8pt\nunread before move\n").unwrap();
let mut build = request(&mode);
build.world = WorldConfig::new(&mode);
build.world.paths.insert(
ResourceKind::Tex,
vec![
SearchPath::directory(&mode, false),
SearchPath::directory(&texmf, false),
],
);
build.input = seed;
build.output = mode.join("latex.tfx");
let dumped = dump_bundled_format(build, Cancellation::default(), &staging).unwrap();
assert!(dumped.resources.trace.stream_reads.iter().any(|range| {
range.path == mode.join("texsys.aux") && range.offset == 0 && range.bytes == 4
}));
fs::write(project.join("main.tex"), br"\shipout\hbox{\savedrule}\end").unwrap();
let result = |bundle: &Path| {
let mut job = request(&project);
job.entry = Entry::Format(bundle.join("formats/pdflatex/latex.tfx"));
NativeCompiler::default().compile(job)
};
let reference = result(&staging).unwrap();
fs::rename(&staging, &installed).unwrap();
assert!(!staging.exists());
let scratch = installed.join("formats/pdflatex/texsys.aux");
fs::write(&scratch, b"8pt\nunread after move\n").unwrap();
let moved = result(&installed).unwrap();
assert_eq!(moved.pdf, reference.pdf);
assert!(moved.resources.trace.reads.iter().any(|resource| {
resource.path == installed.join("texmf/layout.tex")
}));
fs::write(&scratch, b"9pt\nunread after move\n").unwrap();
let error = result(&installed).err().unwrap();
let message = error.to_string();
assert!(
message.contains("native format source changed") && message.contains(scratch.to_str().unwrap()),
"{message}"
);
fs::remove_file(scratch).unwrap();
let error = result(&installed).err().unwrap();
assert!(error.to_string().contains("native format relocated input not found"), "{error}");
fs::remove_dir_all(root).unwrap();
}
#[test]
fn relocated_format_checks_current_sources_and_consumed_stream_ranges() {
let root = directory("format-relocation").canonicalize().unwrap();