Advance native LaTeX execution and preview
This commit is contained in:
1 parent
91f9d76b16
commit
2741546ca8
414 files changed
+99872
-933
No files matched your search
@@ -0,0 +1,113 @@
|
||||
#[path = "support/native_fonts.rs"]
|
||||
mod native_fonts;
|
||||
use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
process::Command,
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
};
|
||||
fn directory() -> PathBuf {
|
||||
static N: AtomicU64 = AtomicU64::new(0);
|
||||
let p = std::env::temp_dir().join(format!(
|
||||
"texrra-native-statistics-{}-{}",
|
||||
std::process::id(),
|
||||
N.fetch_add(1, Ordering::Relaxed)
|
||||
));
|
||||
fs::create_dir_all(&p).unwrap();
|
||||
p
|
||||
}
|
||||
#[test]
|
||||
fn real_core_and_shipout_statistics_reach_actual_channels_and_preserve_outputs() {
|
||||
let p = directory();
|
||||
let source =
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/native-bootstrap/statistics.tex");
|
||||
let before = fs::read(&source).unwrap();
|
||||
let r = native_fonts::command()
|
||||
.args([
|
||||
"native",
|
||||
"--job",
|
||||
"--initex",
|
||||
"--etex",
|
||||
"--resource-manifest",
|
||||
"resources.json",
|
||||
])
|
||||
.arg(&source)
|
||||
.arg("native.pdf")
|
||||
.current_dir(&p)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(r.status.success(), "{}", String::from_utf8_lossy(&r.stderr));
|
||||
let terminal = String::from_utf8_lossy(&r.stderr);
|
||||
let log = fs::read_to_string(p.join("native.log")).unwrap();
|
||||
assert_eq!(terminal.matches("Route-D resources at shipout:").count(), 2);
|
||||
assert_eq!(log.matches("Route-D resources at shipout:").count(), 2);
|
||||
assert!(!terminal.contains("resource usage at core execution end"));
|
||||
assert_eq!(
|
||||
log.matches("resource usage at core execution end (success)")
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert!(log.contains("1 font instances"));
|
||||
assert!(log.contains("host resources: 2 reads"));
|
||||
assert!(!log.contains("still untouched:"));
|
||||
let output = Command::new("pdftotext")
|
||||
.arg(p.join("native.pdf"))
|
||||
.arg("-")
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
assert_eq!(
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
.matches("Native resource statistics")
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
assert_eq!(
|
||||
fs::read(p.join("statistics.aux")).unwrap(),
|
||||
b"PAGE=1\nPAGE=2\n"
|
||||
);
|
||||
let trace: serde_json::Value =
|
||||
serde_json::from_slice(&fs::read(p.join("resources.json")).unwrap()).unwrap();
|
||||
assert!(
|
||||
trace["reads"].as_array().unwrap().len() > 2,
|
||||
"actual PFB/map resolution follows the core statistics boundary"
|
||||
);
|
||||
assert_eq!(fs::read(&source).unwrap(), before);
|
||||
fs::remove_dir_all(p).unwrap();
|
||||
}
|
||||
#[test]
|
||||
fn level_one_is_log_only_and_failed_jobs_keep_real_statistics_and_existing_pdf() {
|
||||
let p = directory();
|
||||
for (body, ok) in [
|
||||
(r"\tracingstats=1\end", true),
|
||||
(r"\tracingstats=1\relax\badcommand\end", false),
|
||||
] {
|
||||
let source = format!(r"\catcode123=1\catcode125=2{body}");
|
||||
fs::write(p.join("source.tex"), &source).unwrap();
|
||||
fs::write(p.join("native.pdf"), b"KEEP").unwrap();
|
||||
let r = native_fonts::command()
|
||||
.args([
|
||||
"native",
|
||||
"--job",
|
||||
"--initex",
|
||||
"--etex",
|
||||
"source.tex",
|
||||
"native.pdf",
|
||||
])
|
||||
.current_dir(&p)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(r.status.success(), ok);
|
||||
let terminal = String::from_utf8_lossy(&r.stderr);
|
||||
assert!(!terminal.contains("resource usage at core execution end"));
|
||||
let log = fs::read_to_string(p.join("native.log")).unwrap();
|
||||
assert!(log.contains(if ok {
|
||||
"core execution end (success)"
|
||||
} else {
|
||||
"core execution end (failure)"
|
||||
}));
|
||||
assert_eq!(fs::read(p.join("native.pdf")).unwrap(), b"KEEP");
|
||||
assert_eq!(fs::read_to_string(p.join("source.tex")).unwrap(), source);
|
||||
}
|
||||
fs::remove_dir_all(p).unwrap();
|
||||
}
|
||||
Reference in new issue
Block a user