Skip to content

Commit 686fa44

Browse files
kgrossberg
authored andcommitted
Less verbose runtests output. Don't ocamlbuild by default (pass --build as an arg to build).
1 parent 75bd057 commit 686fa44

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
**/*~
22
**/*.tmproj
3-
3+
_build

‎ml-proto/runtests.py‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99

1010
class RunTests(unittest.TestCase):
1111
def _runTestFile(self, shortName, fileName, interpreterPath):
12-
print("\n// %s" % shortName)
13-
sys.stdout.flush()
14-
1512
logPath = fileName.replace("test/", "test/output/").replace(".wasm", ".wasm.log")
1613
try:
1714
os.remove(logPath)
1815
except OSError:
1916
pass
2017

21-
commandStr = ("%s %s | tee %s") % (interpreterPath, fileName, logPath)
18+
commandStr = ("%s %s > %s") % (interpreterPath, fileName, logPath)
2219
exitCode = subprocess.call(commandStr, shell=True)
2320
self.assertEqual(0, exitCode, "test runner failed with exit code %i" % exitCode)
2421

2522
try:
2623
expected = open(fileName.replace("test/", "test/expected-output/").replace(".wasm", ".wasm.log"))
2724
except IOError:
28-
print("// WARNING: No expected output found for this test")
25+
# print("// WARNING: No expected output found for %s" % fileName)
2926
return
3027

3128
output = open(logPath)
@@ -47,24 +44,34 @@ def generate_test_cases(cls, interpreterPath, files):
4744
testCase = generate_test_case(rec)
4845
setattr(cls, attrName, testCase)
4946

50-
def rebuild_interpreter():
51-
interpreterPath = os.path.abspath("src/main.native")
47+
def find_interpreter(path):
48+
if not os.path.exists(path):
49+
raise Exception("Interpreter has not been built. Looked for %s" % path)
5250

53-
print("// building main.native")
51+
def rebuild_interpreter(path):
52+
print("// building %s" % path)
5453
sys.stdout.flush()
5554
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray", "main.native"], cwd=os.path.abspath("src"))
5655
if (exitCode != 0):
5756
raise Exception("ocamlbuild failed with exit code %i" % exitCode)
58-
59-
return interpreterPath
57+
if not os.path.exists(path):
58+
raise Exception("Interpreter has not been built. Looked for %s" % path)
6059

6160
if __name__ == "__main__":
61+
interpreterPath = os.path.abspath("src/main.native")
62+
6263
try:
6364
os.makedirs("test/output/")
6465
except OSError:
6566
pass
6667

67-
interpreterPath = rebuild_interpreter()
68+
shouldBuildInterpreter = ("--build" in sys.argv)
69+
if shouldBuildInterpreter:
70+
sys.argv.remove("--build")
71+
rebuild_interpreter(interpreterPath)
72+
else:
73+
find_interpreter(interpreterPath)
74+
6875
testFiles = glob.glob("test/*.wasm")
6976
generate_test_cases(RunTests, interpreterPath, testFiles)
7077
unittest.main()

0 commit comments

Comments
 (0)