|
1 | 1 | import sys
|
2 | 2 | import subprocess
|
3 | 3 | import os
|
4 |
| -import tempfile |
5 | 4 |
|
6 | 5 | # We want to print line endings normally, but each line should be a b'' string
|
7 | 6 | def clean(x):
|
8 | 7 | lines = []
|
9 |
| - for l in x.splitlines(): |
10 |
| - if b'examples' in l: |
11 |
| - lines.append(str(l.replace(b'\\',b'/'))) |
| 8 | + for line in x.splitlines(): |
| 9 | + if b'examples' in line: |
| 10 | + lines.append(str(line.replace(b'\\',b'/'))) |
12 | 11 | else:
|
13 |
| - lines.append(str(l)) |
| 12 | + lines.append(str(line)) |
14 | 13 | return '\n'.join(lines)
|
15 | 14 |
|
16 | 15 | def check_error(run_result,
|
@@ -45,29 +44,28 @@ def check_error(run_result,
|
45 | 44 | def main() -> int:
|
46 | 45 | m4_path = sys.argv[1]
|
47 | 46 | input_path = sys.argv[2]
|
48 |
| - tmproot = sys.argv[3] |
49 |
| - workdir = sys.argv[4] |
| 47 | + workdir = sys.argv[3] |
50 | 48 | examples_path = workdir + '/examples'
|
51 | 49 | if ':' in examples_path:
|
52 | 50 | examples_path = examples_path.partition(':')[2]
|
53 |
| - with open(input_path, 'rb') as input_file, tempfile.TemporaryDirectory(dir=tmproot) as tmpdir: |
| 51 | + with open(input_path, 'rb') as input_file: |
54 | 52 | expected_out = bytes()
|
55 | 53 | expected_err = bytes()
|
56 | 54 | ignore_err = False
|
57 | 55 | m4_input = bytes()
|
58 |
| - for l in input_file.read().splitlines(): |
59 |
| - if l.startswith(b'dnl @ expected status: '): |
60 |
| - expected_code = int(l[len('dnl @ expected status: '):].rstrip()) |
61 |
| - if l.startswith(b'dnl @ extra options: '): |
62 |
| - args = l[len('dnl @ extra options: '):].rstrip().decode() |
63 |
| - if l.startswith(b'dnl @result{}'): |
64 |
| - expected_out += l[len('dnl @result{}'):] + os.linesep.encode() |
65 |
| - if l.startswith(b'dnl @error{}'): |
66 |
| - expected_err += l[len('dnl @error{}'):] + os.linesep.encode() |
67 |
| - if l.startswith(b'dnl @ expected error: ignore'): |
| 56 | + for line in input_file.read().splitlines(): |
| 57 | + if line.startswith(b'dnl @ expected status: '): |
| 58 | + expected_code = int(line[len('dnl @ expected status: '):].rstrip()) |
| 59 | + if line.startswith(b'dnl @ extra options: '): |
| 60 | + args = line[len('dnl @ extra options: '):].rstrip().decode() |
| 61 | + if line.startswith(b'dnl @result{}'): |
| 62 | + expected_out += line[len('dnl @result{}'):] + os.linesep.encode() |
| 63 | + if line.startswith(b'dnl @error{}'): |
| 64 | + expected_err += line[len('dnl @error{}'):] + os.linesep.encode() |
| 65 | + if line.startswith(b'dnl @ expected error: ignore'): |
68 | 66 | ignore_err = True
|
69 |
| - if not l.startswith(b'dnl @'): |
70 |
| - m4_input += l + b'\n' |
| 67 | + if not line.startswith(b'dnl @'): |
| 68 | + m4_input += line + b'\n' |
71 | 69 | runargs = []
|
72 | 70 | runargs.append(m4_path)
|
73 | 71 | runargs.append('-d')
|
|
0 commit comments