87 lines
3.2 KiB
Rust
87 lines
3.2 KiB
Rust
#[path = "support/native_fonts.rs"]
|
|
mod native_fonts;
|
|
use std::{fs, path::PathBuf};
|
|
#[test]
|
|
fn real_paragraph_channels_pdf_bytes_aux_and_failure_protection() {
|
|
let dir = std::env::temp_dir().join(format!(
|
|
"texrra-native-paragraph-trace-{}",
|
|
std::process::id()
|
|
));
|
|
fs::create_dir_all(&dir).unwrap();
|
|
let original =
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/native-bootstrap/native-job.tex");
|
|
let before = fs::read(&original).unwrap();
|
|
let mut pdf = None;
|
|
for level in [0, 1] {
|
|
for online in [0, 1] {
|
|
let source = format!(
|
|
r"\catcode123=1\catcode125=2\pdfoutput=1\pdfpkresolution=600\tracingparagraphs={level}\tracingonline={online}\input {}",
|
|
original.display()
|
|
);
|
|
fs::write(dir.join("probe.tex"), &source).unwrap();
|
|
let r = native_fonts::command()
|
|
.args([
|
|
"native",
|
|
"--job",
|
|
"--initex",
|
|
"--etex",
|
|
"probe.tex",
|
|
"native.pdf",
|
|
])
|
|
.current_dir(&dir)
|
|
.output()
|
|
.unwrap();
|
|
assert!(r.status.success(), "{}", String::from_utf8_lossy(&r.stderr));
|
|
let log = fs::read_to_string(dir.join("native.log")).unwrap();
|
|
let terminal = String::from_utf8_lossy(&r.stderr);
|
|
assert_eq!(
|
|
log.matches("@firstpass").count(),
|
|
if level > 0 { 6 } else { 0 }
|
|
);
|
|
assert_eq!(
|
|
terminal.matches("@firstpass").count(),
|
|
if level > 0 && online > 0 { 6 } else { 0 }
|
|
);
|
|
let bytes = fs::read(dir.join("native.pdf")).unwrap();
|
|
if let Some(expected) = &pdf {
|
|
assert!(
|
|
&bytes == expected,
|
|
"trace controls changed actual PDF bytes"
|
|
);
|
|
} else {
|
|
pdf = Some(bytes);
|
|
}
|
|
assert_eq!(
|
|
fs::read(dir.join("pages.aux")).unwrap(),
|
|
b"FIRST-PAGE=1\nLAST-PAGE=4\n"
|
|
);
|
|
assert_eq!(fs::read_to_string(dir.join("probe.tex")).unwrap(), source);
|
|
}
|
|
}
|
|
let source = r"\catcode123=1\catcode125=2\font\f=cmr10\f\tracingparagraphs=1\hsize=60pt\parfillskip=0pt plus1fil\noindent Original paragraph with actual trace.\par\badcommand\end";
|
|
fs::write(dir.join("probe.tex"), source).unwrap();
|
|
fs::write(dir.join("native.pdf"), b"KEEP").unwrap();
|
|
let r = native_fonts::command()
|
|
.args([
|
|
"native",
|
|
"--job",
|
|
"--initex",
|
|
"--etex",
|
|
"probe.tex",
|
|
"native.pdf",
|
|
])
|
|
.current_dir(&dir)
|
|
.output()
|
|
.unwrap();
|
|
assert!(!r.status.success());
|
|
assert!(
|
|
fs::read_to_string(dir.join("native.log"))
|
|
.unwrap()
|
|
.contains("@firstpass")
|
|
);
|
|
assert_eq!(fs::read(dir.join("native.pdf")).unwrap(), b"KEEP");
|
|
assert_eq!(fs::read_to_string(dir.join("probe.tex")).unwrap(), source);
|
|
assert_eq!(fs::read(&original).unwrap(), before);
|
|
fs::remove_dir_all(dir).unwrap();
|
|
}
|