Skip to content

Add a simple automated test runner for all the .wasm files in the test directory #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ml-proto/runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

import os.path
import unittest
import subprocess
import glob

class RunTests(unittest.TestCase):
def _runTestFile(self, shortName, fileName, interpreterPath):
print("\n// %s" % shortName)
exitCode = subprocess.call([interpreterPath, fileName])
self.assertEqual(0, exitCode, "test runner failed with exit code %i" % exitCode)

def generate_test_cases(cls, interpreterPath, files):
for fileName in files:
absFileName = os.path.abspath(fileName)
attrName = fileName
testCase = lambda self : self._runTestFile(attrName, absFileName, interpreterPath)
setattr(cls, attrName, testCase)

def rebuild_interpreter():
interpreterPath = os.path.abspath("src/main.native")

print("// building main.native")
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray", "main.native"], cwd=os.path.abspath("src"))
if (exitCode != 0):
raise Exception("ocamlbuild failed with exit code %i" % exitCode)

return interpreterPath

if __name__ == "__main__":
interpreterPath = rebuild_interpreter()
generate_test_cases(RunTests, interpreterPath, glob.glob("test/*.wasm"))
unittest.main()