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

Add semantic test runner

parent 713da1c4
......@@ -111,7 +111,8 @@ class Environment:
mode_flag = {
TestMode.lexer: "--lextest",
TestMode.syntax: "--parsetest",
TestMode.ast: "--print-ast"
TestMode.ast: "--print-ast",
TestMode.semantic: "--check"
}[mode]
cmd = [self.mj_run_cmd, mode_flag] + list(args)
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:
failed = 0
count = 0
for test_case in self.test_cases[mode]:
try:
ret = self._run_test_case(test_case)
if ret is False or not ret.is_correct():
failed += 1
else:
self._add_correct_test_case(test_case)
count += 1
except KeyboardInterrupt:
return RunResult(count, failed)
return RunResult(count, failed)
def _func(self, test_case: 'TestCase'):
......@@ -425,3 +428,4 @@ TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest)
import mjtest.test.syntax_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