Commit 23eee370 authored by Johannes Bechberger's avatar Johannes Bechberger

Add semantic test runner

parent 713da1c4
...@@ -111,7 +111,8 @@ class Environment: ...@@ -111,7 +111,8 @@ class Environment:
mode_flag = { mode_flag = {
TestMode.lexer: "--lextest", TestMode.lexer: "--lextest",
TestMode.syntax: "--parsetest", TestMode.syntax: "--parsetest",
TestMode.ast: "--print-ast" TestMode.ast: "--print-ast",
TestMode.semantic: "--check"
}[mode] }[mode]
cmd = [self.mj_run_cmd, mode_flag] + list(args) cmd = [self.mj_run_cmd, mode_flag] + list(args)
return execute(cmd, timeout=self.timeout) return execute(cmd, timeout=self.timeout)
......
from mjtest.environment import TestMode
from mjtest.test.syntax_tests import BasicSyntaxTest
from mjtest.test.tests import TestCase
class BasicSemanticTest(BasicSyntaxTest):
FILE_ENDINGS = [".invalid.mj", ".valid.mj", ".mj", ".invalid.java", ".java"]
MODE = TestMode.semantic
TestCase.TEST_CASE_CLASSES[TestMode.semantic].append(BasicSemanticTest)
\ No newline at end of file
...@@ -127,12 +127,15 @@ class TestSuite: ...@@ -127,12 +127,15 @@ class TestSuite:
failed = 0 failed = 0
count = 0 count = 0
for test_case in self.test_cases[mode]: for test_case in self.test_cases[mode]:
ret = self._run_test_case(test_case) try:
if ret is False or not ret.is_correct(): ret = self._run_test_case(test_case)
failed += 1 if ret is False or not ret.is_correct():
else: failed += 1
self._add_correct_test_case(test_case) else:
count += 1 self._add_correct_test_case(test_case)
count += 1
except KeyboardInterrupt:
return RunResult(count, failed)
return RunResult(count, failed) return RunResult(count, failed)
def _func(self, test_case: 'TestCase'): def _func(self, test_case: 'TestCase'):
...@@ -425,3 +428,4 @@ TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest) ...@@ -425,3 +428,4 @@ TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest)
import mjtest.test.syntax_tests import mjtest.test.syntax_tests
import mjtest.test.ast_tests import mjtest.test.ast_tests
import mjtest.test.semantic_tests
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment