Skip to content

Commit f4e2228

Browse files
author
Austin Clements
committed
Pass --latex-cmd through test run script
1 parent d810cc5 commit f4e2228

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test/run

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@ import subprocess
77
import re
88
import difflib
99
import shutil
10+
import shlex
1011

1112
failures = 0
1213

1314
def main():
1415
parser = argparse.ArgumentParser()
1516
parser.add_argument('--latexrun', default='../latexrun',
1617
help='Path to latexrun (default: %(default)s)')
18+
parser.add_argument('--latex-cmd', help='Passed to latexrun')
1719
parser.add_argument('input', nargs='*', help='Input test file')
1820
args = parser.parse_args()
1921

22+
latexrun_args = []
23+
if args.latex_cmd is not None:
24+
latexrun_args.extend(['--latex-cmd', args.latex_cmd])
25+
2026
os.makedirs('output', exist_ok=True)
2127

2228
for inp in args.input:
23-
test(args.latexrun, inp)
29+
test(args.latexrun, latexrun_args, inp)
2430

2531
sys.exit(1 if failures else 0)
2632

27-
def check(label, passed=False, passed_expect=True):
33+
def check(label, latexrun_args, passed=False, passed_expect=True):
2834
global failures
2935
if passed_expect and not passed:
3036
failures += 1
@@ -34,11 +40,12 @@ def check(label, passed=False, passed_expect=True):
3440
(False, False): ('BROKEN', 3),
3541
(True, True): ('PASS', 2)}[(passed, passed_expect)]
3642

43+
label += ''.join(' ' + shlex.quote(a) for a in latexrun_args)
3744
print('\x1b[1;3%dm%-6s\x1b[0m %s' % (color, msg, label))
3845

3946
INDENT = 7 * ' '
4047

41-
def test(latexrun_path, input_path):
48+
def test(latexrun_path, latexrun_args, input_path):
4249
testname = os.path.splitext(input_path.split('/')[0])[0]
4350

4451
# Get expectations
@@ -77,15 +84,15 @@ def test(latexrun_path, input_path):
7784
latexrun_path = os.path.relpath(latexrun_path, start=input_dir)
7885

7986
p = subprocess.Popen([latexrun_path, '-o', outpath,
80-
os.path.basename(input_path)],
87+
os.path.basename(input_path)] + latexrun_args,
8188
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
8289
cwd = input_dir or None)
8390
output = p.stdout.read().decode('ascii', errors='surrogateescape')
8491
status = p.wait()
8592

8693
# Check results
8794
if output != output_expect:
88-
check(testname, False, passed_expect)
95+
check(testname, latexrun_args, False, passed_expect)
8996
open('output/%s.output' % testname, 'w', errors='surrogateescape')\
9097
.write(output)
9198
msg = []
@@ -104,10 +111,10 @@ def test(latexrun_path, input_path):
104111
sys.stdout.buffer.write('\n'.join(msg).encode(errors='surrogateescape'))
105112
print()
106113
elif status != status_expect:
107-
check(testname, False, passed_expect)
114+
check(testname, latexrun_args, False, passed_expect)
108115
print(INDENT + 'Expected status %d, got %d' % (status_expect, status))
109116
else:
110-
check(testname, True, passed_expect)
117+
check(testname, latexrun_args, True, passed_expect)
111118

112119
if __name__ == '__main__':
113120
main()

0 commit comments

Comments
 (0)