Apply Web2C TCX tables to native byte streams
This commit is contained in:
1 parent
3bb2330676
commit
509f229a52
13 files changed
+393
-38
No files matched your search
@@ -70,6 +70,98 @@ const CASES: &[(&str, &str)] = &[
|
||||
),
|
||||
];
|
||||
|
||||
#[test]
|
||||
fn tcx_streams_match_pdftex_for_nonidentity_input_and_raw_output() {
|
||||
let root = directory();
|
||||
let native = root.join("native");
|
||||
let reference = root.join("reference");
|
||||
let mut source = br"\catcode123=1 \catcode125=2 \catcode94=7
|
||||
\catcode144=12 \catcode145=12 \catcode169=12
|
||||
\newlinechar=-1 \endlinechar=-1
|
||||
\immediate\openout0=result.dat
|
||||
\immediate\write0{CODE=\number"
|
||||
.to_vec();
|
||||
source.push(96); // TeX alphabetic constant introducer
|
||||
source.push(0x80);
|
||||
source.extend_from_slice(
|
||||
br"; PRINT=^^90; HIDDEN=^^91}
|
||||
\openin1=data.txt
|
||||
\readline1 to\line
|
||||
\immediate\write0{DATA=\line}
|
||||
\newlinechar=169
|
||||
\shipout\hbox{\write0{LATE^^a9^^90}\vrule width1pt height1pt}
|
||||
\message{MESSAGE-^^90}
|
||||
\immediate\write17{LOG-^^90}
|
||||
\immediate\closeout0
|
||||
\end
|
||||
",
|
||||
);
|
||||
for side in [&native, &reference] {
|
||||
fs::create_dir(side).unwrap();
|
||||
fs::write(side.join("probe.tex"), &source).unwrap();
|
||||
fs::write(side.join("data.txt"), [0x80, b'\n']).unwrap();
|
||||
fs::write(side.join("table.tcx"), b"0x80 0x90 1\n0x97 0x91 0\n").unwrap();
|
||||
}
|
||||
let ran = Command::new("pdftex")
|
||||
.args([
|
||||
"-ini",
|
||||
"-etex",
|
||||
"-interaction=nonstopmode",
|
||||
"-halt-on-error",
|
||||
])
|
||||
.arg(format!(
|
||||
"-translate-file={}",
|
||||
reference.join("table.tcx").display()
|
||||
))
|
||||
.arg("probe.tex")
|
||||
.current_dir(&reference)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
ran.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&ran.stdout)
|
||||
);
|
||||
let ran = Command::new(env!("CARGO_BIN_EXE_texrra"))
|
||||
.args([
|
||||
"native",
|
||||
"--job",
|
||||
"--initex",
|
||||
"--etex",
|
||||
"--input-profile",
|
||||
"tex8bit",
|
||||
"--translate-file",
|
||||
"table.tcx",
|
||||
"probe.tex",
|
||||
"native.pdf",
|
||||
])
|
||||
.current_dir(&native)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
ran.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&ran.stderr)
|
||||
);
|
||||
let bytes = fs::read(native.join("result.dat")).unwrap();
|
||||
assert_eq!(bytes, fs::read(reference.join("result.dat")).unwrap());
|
||||
assert_eq!(
|
||||
bytes,
|
||||
b"CODE=144; PRINT=\x80; HIDDEN=^^91\nDATA=\x80\nLATE\n\x80\n"
|
||||
);
|
||||
for marker in [b"MESSAGE-\x80".as_slice(), b"LOG-\x80".as_slice()] {
|
||||
for log in [native.join("native.log"), reference.join("probe.log")] {
|
||||
assert!(
|
||||
fs::read(log)
|
||||
.unwrap()
|
||||
.windows(marker.len())
|
||||
.any(|part| part == marker)
|
||||
);
|
||||
}
|
||||
}
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn actual_stream_file_bytes_match_real_pdftex_initex() {
|
||||
let root = directory();
|
||||
|
||||
Reference in new issue
Block a user