Put native PDF warnings on separate diagnostic lines

This commit is contained in:
gloamxun committed 2026-11-21 06:45:35 +08:00
1 parent 75d3667397
commit 3ff339341b
4 files changed
+41 -5

No files matched your search

@@ -100,7 +100,7 @@ impl Executor {
if let Some(warning) = self.state.glyph_unicode.define(glyph, &value) {
let text = format!("native PDF warning: {warning}");
files
.observe_message(&text)
.observe_diagnostic(WriteDestination::TerminalAndLog, &format!("{text}\n"))
.map_err(|e| self.error(e, self.current))?;
self.events.push(Event::Message {
text,
@@ -200,7 +200,7 @@ impl Executor {
"native PDF warning: object streams require PDF 1.5 or greater; disabled"
.to_string();
files
.observe_message(&text)
.observe_diagnostic(WriteDestination::TerminalAndLog, &format!("{text}\n"))
.map_err(|e| self.error(e, self.current))?;
self.events.push(Event::Message {
text,
+5 -2
View File
@@ -33,7 +33,7 @@ use texrra_tex_core::{
execution::{
Cancellation, ExecutionFailure, Executor, FormatImage, InputProfile, JobTime, Limits,
NativeSession, RevisionError, RevisionExecution, RevisionFailure, RevisionJob, SourceFile,
SourceProvider, State,
SourceProvider, State, WriteDestination,
},
render::DisplayList,
resources::{FileWorld, InputSnapshot, ResourceTrace, ResourceVersion, WorldConfig},
@@ -1123,7 +1123,10 @@ impl CompileJob {
evidence.diagnostics = export_diagnostics.clone();
notify(&request, revision, CompileStage::Exported, &cancellation)?;
for warning in &export_diagnostics {
files.observe_message(&format!("native PDF warning: {warning}"))?;
files.observe_diagnostic(
WriteDestination::TerminalAndLog,
&format!("native PDF warning: {warning}\n"),
)?;
}
evidence.phase = AttemptPhase::Finishing;
let finished = files.finish();
+4 -1
View File
@@ -348,7 +348,10 @@ fn original_a3_resume_uses_real_host_and_matches_independent_full_jobs() {
.unwrap();
for warning in &pdf.diagnostics {
files
.observe_message(&format!("native PDF warning: {warning}"))
.observe_diagnostic(
WriteDestination::TerminalAndLog,
&format!("native PDF warning: {warning}\n"),
)
.unwrap();
}
files.finish().unwrap();
+30
View File
@@ -181,3 +181,33 @@ fn local_structure_action_references_the_shipped_structure_and_later_page() {
assert_eq!(destination[1].as_name().unwrap(), b"FitR");
fs::remove_dir_all(root).unwrap();
}
#[test]
fn each_export_warning_starts_on_its_own_log_line() {
let root = std::env::temp_dir().join(format!("texrra-pdf-warning-lines-{}", std::process::id()));
let source = r"\catcode123=1 \catcode125=2
\pdfoutput=1 \pdfmajorversion=2 \pdfminorversion=0
\pdfcompresslevel=0 \pdfobjcompresslevel=0
\immediate\pdfobj{<< /Type /StructElem /S /Sect >>}
\count1=\pdflastobj
\shipout\hbox{\pdfdest struct \count1 name{first} xyz
\pdfdest struct \count1 name{first} xyz
\pdfdest struct \count1 name{second} xyz
\pdfdest struct \count1 name{second} xyz
\vrule width4pt height3pt}
\message{LAST-MESSAGE}
\end";
let doc = compile(&root, source, true);
assert_eq!(doc.get_pages().len(), 1);
let transcript = fs::read_to_string(root.join("native/probe.log")).unwrap();
let descriptions: Vec<_> = transcript
.lines()
.filter_map(|line| line.strip_prefix("native PDF warning: "))
.collect();
assert_eq!(descriptions.len(), 2, "{transcript}");
for (description, target) in descriptions.iter().zip(["first", "second"]) {
assert!(description.contains(&format!("name{{{target}}}")));
assert!(description.ends_with("duplicate ignored"));
}
fs::remove_dir_all(root).unwrap();
}