Debian Codegraph @

scripts/run-tests.py

raw
1 #!/usr/bin/env python3
2
3 import glob
4 import os
5 import subprocess
6 import sys
7
8
9 argv0_dir = os.path.dirname(sys.argv[0])
10 project_dir = os.path.abspath(os.path.join(argv0_dir, ".."))
11 test_dir = os.path.join(project_dir, "test")
12 program = os.path.abspath(os.path.join("md2html", "md2html"))
13
14 if __name__ == "__main__":
15 err_count = 0
16
17 os.chdir(test_dir)
18
19 for testsuite in glob.glob('*.txt'):
20 print("Testing {}".format(testsuite))
21 sys.stdout.flush()
22 sys.stderr.flush()
23 args = [
24 sys.executable,
25 "run-testsuite.py",
26 "-s", testsuite,
27 "-p", str(program)
28 ]
29 p = subprocess.run(args)
30 if p.returncode != 0:
31 err_count += 1
32 print()
33
34 print("Testing pathological inputs:")
35 sys.stdout.flush()
36 sys.stderr.flush()
37 args = [
38 sys.executable,
39 "pathological-tests.py",
40 "-p", str(program)
41 ]
42 subprocess.run(args)
43 if p.returncode != 0:
44 err_count += 1
45
46 sys.exit(err_count)