Commit b8bd79dd authored by Johannes Bechberger's avatar Johannes Bechberger

Improve `compile-firm` test mode

Move all big test cases should into the folder `big`
parent 90c1cc2d
...@@ -99,6 +99,8 @@ class Environment: ...@@ -99,6 +99,8 @@ class Environment:
except IOError: except IOError:
pass pass
self.report_dir = os.path.join(self.report_dir, report_subdir or datetime.now().strftime("%d-%m-%y_%H-%M-%S")) self.report_dir = os.path.join(self.report_dir, report_subdir or datetime.now().strftime("%d-%m-%y_%H-%M-%S"))
if not os.path.exists(self.report_dir):
os.mkdir(self.report_dir)
else: else:
self.report_dir = None self.report_dir = None
logging.basicConfig(level=self.LOG_LEVELS[log_level]) logging.basicConfig(level=self.LOG_LEVELS[log_level])
......
import shutil import shutil
from mjtest.environment import Environment, TestMode, TEST_MODES from mjtest.environment import Environment, TestMode, TEST_MODES, get_test_dirname
from mjtest.test.tests import TestCase, BasicTestResult from mjtest.test.tests import TestCase, BasicTestResult
from os import path from os import path
...@@ -20,7 +20,17 @@ class BasicSyntaxTest(TestCase): ...@@ -20,7 +20,17 @@ class BasicSyntaxTest(TestCase):
return self._should_succeed return self._should_succeed
def short_name(self) -> str: def short_name(self) -> str:
return path.basename(self.file) test_dir = None
modes = [self.MODE]
if self.MODE in TestMode.USE_TESTS_OF_OTHER:
modes += TestMode.USE_TESTS_OF_OTHER[self.MODE]
for mode in modes:
subdir = path.join(self.env.test_dir, get_test_dirname(mode))
if self.file.startswith(subdir):
test_dir = subdir
break
assert test_dir != None
return path.relpath(self.file, test_dir)
def run(self) -> BasicTestResult: def run(self) -> BasicTestResult:
out, err, rtcode = self.env.run_mj_command(self.MODE, self.preprocessed_file) out, err, rtcode = self.env.run_mj_command(self.MODE, self.preprocessed_file)
......
...@@ -41,8 +41,6 @@ class TestSuite: ...@@ -41,8 +41,6 @@ class TestSuite:
def _load_test_case_type(self, type: str): def _load_test_case_type(self, type: str):
dir = join(self.env.test_dir, get_test_dirname(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:
...@@ -66,12 +64,19 @@ class TestSuite: ...@@ -66,12 +64,19 @@ class TestSuite:
file_names = [] file_names = []
for root, dirs, files in os.walk(dir): for root, dirs, files in os.walk(dir):
base = os.path.relpath(root, dir) base = os.path.relpath(root, dir)
dirname = os.path.dirname(base)
if dir == root: if dir == root:
file_names.extend(files) file_names.extend(files)
elif base == ".preprocessed": elif ".preprocessed" in base or (dirname.startswith(".") and dirname != "."):
continue continue
else: elif base.startswith("big") and get_test_dirname(mode) == "exec" and self.env.only_small_exec_tests:
file_names.extend(join(base, file) for file in files) continue
elif base == ".":
continue
for file in files:
p = join(base, file)
if not p.startswith("."):
file_names.append(p)
for file in sorted(file_names): for file in sorted(file_names):
if not TestCase.has_valid_file_ending(self.env.mode, file): if not TestCase.has_valid_file_ending(self.env.mode, file):
_LOG.debug("Skip file " + file) _LOG.debug("Skip file " + file)
...@@ -161,7 +166,6 @@ class TestSuite: ...@@ -161,7 +166,6 @@ class TestSuite:
self._add_correct_test_case(test_case) self._add_correct_test_case(test_case)
return result return result
def _run_test_case(self, test_case: 'TestCase') -> Optional['TestResult']: def _run_test_case(self, test_case: 'TestCase') -> Optional['TestResult']:
try: try:
ret = test_case.run() ret = test_case.run()
...@@ -281,6 +285,7 @@ class TestResult: ...@@ -281,6 +285,7 @@ class TestResult:
return self.error_code == 0 return self.error_code == 0
def store_at(self, file: str): def store_at(self, file: str):
os.makedirs(os.path.dirname(file), exist_ok=True)
with open(file, "w") as f: with open(file, "w") as f:
print(self.long_message(), file=f) print(self.long_message(), file=f)
......
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