Commit 06151285 authored by Johannes Bechberger's avatar Johannes Bechberger

Merge `compile-firm` and `exec` folder

parent a546fdae
...@@ -40,6 +40,8 @@ if True:#__name__ == '__main__': ...@@ -40,6 +40,8 @@ if True:#__name__ == '__main__':
# help="Directory that contains all test cases, default is the 'tests' directory") # help="Directory that contains all test cases, default is the 'tests' directory")
parser.add_argument("--only_incorrect_tests", action="store_true", default=False, parser.add_argument("--only_incorrect_tests", action="store_true", default=False,
help="Only run the tests that were incorrect the last run") help="Only run the tests that were incorrect the last run")
parser.add_argument("--all_exec_tests", action="store_true", default=False,
help="Run all exec (compile-firm...) tests, not only the small ones")
parser.add_argument("--produce_no_reports", action="store_true", default=False, parser.add_argument("--produce_no_reports", action="store_true", default=False,
help="Produce no long reports besides the command line output") help="Produce no long reports besides the command line output")
parser.add_argument("--produce_all_reports", action="store_true", default=False, parser.add_argument("--produce_all_reports", action="store_true", default=False,
......
...@@ -25,7 +25,7 @@ class TestMode: ...@@ -25,7 +25,7 @@ class TestMode:
semantic = "semantic" semantic = "semantic"
comile_firm = "compile-firm" compile_firm = "compile-firm"
exec = "exec" exec = "exec"
...@@ -34,7 +34,17 @@ class TestMode: ...@@ -34,7 +34,17 @@ class TestMode:
} }
""" All 'success' tests of the n.th mode can used as 'success' tests for the n-1.th mode""" """ All 'success' tests of the n.th mode can used as 'success' tests for the n-1.th mode"""
TEST_MODES = [TestMode.lexer, TestMode.syntax, TestMode.ast, TestMode.semantic, TestMode.comile_firm, TestMode.exec] TEST_MODES = [TestMode.lexer, TestMode.syntax, TestMode.ast, TestMode.semantic, TestMode.compile_firm, TestMode.exec]
def get_test_dirname(mode: str) -> str:
d = {
TestMode.compile_firm: "exec"
}
if mode not in d:
return mode
return d[mode]
class Environment: class Environment:
...@@ -50,7 +60,8 @@ class Environment: ...@@ -50,7 +60,8 @@ class Environment:
timeout: int = 30, report_dir: str = "", log_level: str = "warn", timeout: int = 30, report_dir: str = "", log_level: str = "warn",
produce_no_reports: bool = True, output_no_incorrect_reports: bool = False, produce_no_reports: bool = True, output_no_incorrect_reports: bool = False,
produce_all_reports: bool = False, report_subdir: str = None, produce_all_reports: bool = False, report_subdir: str = None,
ci_testing: bool = False, color: bool = False): ci_testing: bool = False, color: bool = False,
all_exec_tests: bool = True):
if color: if color:
force_colored_output() force_colored_output()
self.mode = mode self.mode = mode
...@@ -97,6 +108,7 @@ class Environment: ...@@ -97,6 +108,7 @@ class Environment:
self._tmp_file_ctr = 0 self._tmp_file_ctr = 0
self._already_preprocessed_files = set() self._already_preprocessed_files = set()
self._pid_tmpdirs = {} # type: Dict[int, str] self._pid_tmpdirs = {} # type: Dict[int, str]
self.only_small_exec_tests = not all_exec_tests
def create_tmpfile(self) -> str: def create_tmpfile(self) -> str:
self._tmp_file_ctr += 1 self._tmp_file_ctr += 1
...@@ -130,7 +142,7 @@ class Environment: ...@@ -130,7 +142,7 @@ class Environment:
TestMode.syntax: "--parsetest", TestMode.syntax: "--parsetest",
TestMode.ast: "--print-ast", TestMode.ast: "--print-ast",
TestMode.semantic: "--check", TestMode.semantic: "--check",
TestMode.comile_firm: "--compile-firm" TestMode.compile_firm: "--compile-firm"
}[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)
......
...@@ -16,7 +16,7 @@ class JavaExecTest(BasicSyntaxTest): ...@@ -16,7 +16,7 @@ class JavaExecTest(BasicSyntaxTest):
FILE_ENDINGS = [".java"] FILE_ENDINGS = [".java"]
OUTPUT_FILE_ENDING = ".out" OUTPUT_FILE_ENDING = ".out"
MODE = TestMode.comile_firm MODE = TestMode.compile_firm
def __init__(self, env: Environment, type: str, file: str, preprocessed_file: str): def __init__(self, env: Environment, type: str, file: str, preprocessed_file: str):
super().__init__(env, type, file, preprocessed_file) super().__init__(env, type, file, preprocessed_file)
...@@ -85,4 +85,4 @@ class JavaExecTest(BasicSyntaxTest): ...@@ -85,4 +85,4 @@ class JavaExecTest(BasicSyntaxTest):
return 1 return 1
return 0 return 0
TestCase.TEST_CASE_CLASSES[TestMode.comile_firm].append(JavaExecTest) TestCase.TEST_CASE_CLASSES[TestMode.compile_firm].append(JavaExecTest)
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ from collections import namedtuple ...@@ -2,7 +2,7 @@ from collections import namedtuple
import shutil import shutil
from typing import Optional, List, Tuple, T, Union, Dict from typing import Optional, List, Tuple, T, Union, Dict
import collections import collections
from mjtest.environment import Environment, TestMode, TEST_MODES from mjtest.environment import Environment, TestMode, TEST_MODES, get_test_dirname
from os.path import join, exists, basename from os.path import join, exists, basename
import logging import logging
import os import os
...@@ -39,9 +39,10 @@ class TestSuite: ...@@ -39,9 +39,10 @@ class TestSuite:
for type in types: for type in types:
self._load_test_case_type(type) self._load_test_case_type(type)
def _load_test_case_type(self, type: str): def _load_test_case_type(self, type: str):
dir = join(self.env.test_dir, type) dir = join(self.env.test_dir, get_test_dirname(type))
if get_test_dirname(type) == "exec" and self.env.only_small_exec_tests:
dir = join(dir, "small")
if exists(dir): if exists(dir):
self._load_test_case_dir(type, dir) self._load_test_case_dir(type, dir)
else: else:
...@@ -95,7 +96,7 @@ class TestSuite: ...@@ -95,7 +96,7 @@ class TestSuite:
del self.test_cases[m] del self.test_cases[m]
def _log_file_for_type(self, type: str): def _log_file_for_type(self, type: str):
return join(self.env.test_dir, type, ".mjtest_correct_testcases_" + self.env.mode) return join(self.env.test_dir, get_test_dirname(type), ".mjtest_correct_testcases_" + self.env.mode)
def _add_correct_test_case(self, test_case: 'TestCase'): def _add_correct_test_case(self, test_case: 'TestCase'):
self.correct_test_cases[test_case.type].add(basename(test_case.file)) self.correct_test_cases[test_case.type].add(basename(test_case.file))
......
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