-
Notifications
You must be signed in to change notification settings - Fork 30
/
test-gen-logs.py
executable file
·65 lines (50 loc) · 1.89 KB
/
test-gen-logs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
"""Generate .log files for all .tex files in all test directories."""
import os
import os.path
import subprocess
import sys
import util.ensure_version
commands = "latex", "pdflatex", "xelatex"
rm_ext = "dvi", "pdf", "aux", "out"
if len(sys.argv) == 2:
initial_dir = os.path.join("test", sys.argv[1])
else:
initial_dir = "test"
if not os.path.isdir(initial_dir):
print >>sys.stderr, "Directory %s does not exist - cannot generate logs" % initial_dir
sys.exit(1)
print >>sys.stderr, "Generating logs in %s" % initial_dir
last_dir = None
for dirpath, dirnames, filenames in os.walk(initial_dir):
if os.path.basename(dirpath) == "texmf":
continue
env = os.environ.copy()
if "texmf" in dirnames:
env["TEXINPUTS"] = "./texmf::"
for fname in filenames:
name, ext = os.path.splitext(fname)
if ext != ".tex":
continue
print("Building {0}".format(os.path.join(dirpath, name)))
for command in commands:
texinputs = env.get("TEXINPUTS")
if texinputs:
print "TEXINPUTS=%s" % texinputs
print "Running %r in %r" % (command, dirpath)
ret = subprocess.call(args=(command,
"-interaction=batchmode",
"-file-line-error",
"-recorder",
name),
cwd=dirpath,
env=env)
subprocess.call(args=("mv", "-f", "{0}.log".format(name),
"log.{0}--{1}".format(name, command)),
cwd=dirpath)
subprocess.call(args=("mv", "-f", "{0}.fls".format(name),
"fls.{0}--{1}".format(name, command)),
cwd=dirpath)
rm_files = ["{0}.{1}".format(name, x) for x in rm_ext]
rm_args = ["rm", "-f"]
subprocess.call(args=(rm_args + rm_files), cwd=dirpath)