-
Notifications
You must be signed in to change notification settings - Fork 158
/
run_tests.py
executable file
·112 lines (91 loc) · 3.63 KB
/
run_tests.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
import argparse
import hashlib
import os
import subprocess
import toml
from compiler_tester.tester import (RunException, run, run_test, color,
style, print_check, fg)
def main():
parser = argparse.ArgumentParser(description="LFortran Test Suite")
parser.add_argument("-u", "--update", action="store_true",
help="update all reference results")
parser.add_argument("-l", "--list", action="store_true",
help="list all tests")
parser.add_argument("-t", metavar="TEST",
help="Run a specific test")
parser.add_argument("-v", "--verbose", action="store_true",
help="increase test verbosity")
parser.add_argument("--no-llvm", action="store_true",
help="Skip LLVM tests")
args = parser.parse_args()
update_reference = args.update
list_tests = args.list
specific_test = args.t
verbose = args.verbose
no_llvm = args.no_llvm
# So that the tests find the `lfortran` executable
os.environ["PATH"] = os.path.join(os.getcwd(), "src", "bin") \
+ os.pathsep + os.environ["PATH"]
d = toml.load(open("tests/tests.toml"))
for test in d["test"]:
filename = test["filename"]
if specific_test and filename != specific_test:
continue
tokens = test.get("tokens", False)
ast = test.get("ast", False)
ast_f90 = test.get("ast_f90", False)
ast_cpp = test.get("ast_cpp", False)
ast_cpp_hip = test.get("ast_cpp_hip", False)
ast_openmp = test.get("ast_openmp", False)
asr = test.get("asr", False)
llvm = test.get("llvm", False)
obj = test.get("obj", False)
bin_ = test.get("bin", False)
print(color(style.bold)+"TEST:"+color(style.reset), filename)
if tokens:
run_test("tokens", "lfortran --show-tokens {infile} -o {outfile}",
filename, update_reference)
if ast:
run_test("ast", "lfortran --show-ast {infile} -o {outfile}",
filename, update_reference)
if ast_f90:
run_test("ast_f90", "cpptranslate --show-ast-f90 {infile}",
filename, update_reference)
if ast_cpp:
run_test("ast_cpp", "cpptranslate --show-ast-cpp {infile}",
filename, update_reference)
if ast_cpp_hip:
run_test("ast_cpp_hip", "cpptranslate --show-ast-cpp-hip {infile}",
filename, update_reference)
if ast_openmp:
run_test("ast_openmp", "cpptranslate --show-ast-openmp {infile}",
filename, update_reference)
if asr:
run_test("asr", "lfortran --show-asr {infile} -o {outfile}",
filename, update_reference)
if llvm:
if no_llvm:
print(" * llvm SKIPPED as requested")
else:
run_test("llvm", "lfortran --show-llvm {infile} -o {outfile}",
filename, update_reference)
if obj:
if no_llvm:
print(" * obj SKIPPED as requested")
else:
run_test("obj", "lfortran -c {infile} -o output.o",
filename, update_reference)
if bin_:
run_test("bin", "lfortran {infile} -o {outfile}",
filename, update_reference)
print()
if list_tests:
return
if update_reference:
print("Reference tests updated.")
else:
print("%sTESTS PASSED%s" % (color(fg.green)+color(style.bold),
color(fg.reset)+color(style.reset)))
if __name__ == "__main__":
main()