From 061512851d91516d4db7a7d22026af29ddd6cc62 Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Mon, 28 Nov 2016 20:19:18 +0100 Subject: [PATCH] Merge `compile-firm` and `exec` folder --- mjtest/cli.py | 2 ++ mjtest/environment.py | 20 ++++++++++++++++---- mjtest/test/exec_tests.py | 4 ++-- mjtest/test/tests.py | 9 +++++---- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/mjtest/cli.py b/mjtest/cli.py index 7a8fce7..bbf896f 100644 --- a/mjtest/cli.py +++ b/mjtest/cli.py @@ -40,6 +40,8 @@ if True:#__name__ == '__main__': # help="Directory that contains all test cases, default is the 'tests' directory") parser.add_argument("--only_incorrect_tests", action="store_true", default=False, 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, help="Produce no long reports besides the command line output") parser.add_argument("--produce_all_reports", action="store_true", default=False, diff --git a/mjtest/environment.py b/mjtest/environment.py index 7d5d564..cc6723a 100644 --- a/mjtest/environment.py +++ b/mjtest/environment.py @@ -25,7 +25,7 @@ class TestMode: semantic = "semantic" - comile_firm = "compile-firm" + compile_firm = "compile-firm" exec = "exec" @@ -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""" -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: @@ -50,7 +60,8 @@ class Environment: timeout: int = 30, report_dir: str = "", log_level: str = "warn", produce_no_reports: bool = True, output_no_incorrect_reports: bool = False, 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: force_colored_output() self.mode = mode @@ -97,6 +108,7 @@ class Environment: self._tmp_file_ctr = 0 self._already_preprocessed_files = set() self._pid_tmpdirs = {} # type: Dict[int, str] + self.only_small_exec_tests = not all_exec_tests def create_tmpfile(self) -> str: self._tmp_file_ctr += 1 @@ -130,7 +142,7 @@ class Environment: TestMode.syntax: "--parsetest", TestMode.ast: "--print-ast", TestMode.semantic: "--check", - TestMode.comile_firm: "--compile-firm" + TestMode.compile_firm: "--compile-firm" }[mode] cmd = [self.mj_run_cmd, mode_flag] + list(args) return execute(cmd, timeout=self.timeout) diff --git a/mjtest/test/exec_tests.py b/mjtest/test/exec_tests.py index 4331330..db73724 100644 --- a/mjtest/test/exec_tests.py +++ b/mjtest/test/exec_tests.py @@ -16,7 +16,7 @@ class JavaExecTest(BasicSyntaxTest): FILE_ENDINGS = [".java"] OUTPUT_FILE_ENDING = ".out" - MODE = TestMode.comile_firm + MODE = TestMode.compile_firm def __init__(self, env: Environment, type: str, file: str, preprocessed_file: str): super().__init__(env, type, file, preprocessed_file) @@ -85,4 +85,4 @@ class JavaExecTest(BasicSyntaxTest): return 1 return 0 -TestCase.TEST_CASE_CLASSES[TestMode.comile_firm].append(JavaExecTest) \ No newline at end of file +TestCase.TEST_CASE_CLASSES[TestMode.compile_firm].append(JavaExecTest) \ No newline at end of file diff --git a/mjtest/test/tests.py b/mjtest/test/tests.py index f06b3a6..bb4c2b5 100644 --- a/mjtest/test/tests.py +++ b/mjtest/test/tests.py @@ -2,7 +2,7 @@ from collections import namedtuple import shutil from typing import Optional, List, Tuple, T, Union, Dict 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 import logging import os @@ -39,9 +39,10 @@ class TestSuite: for type in types: self._load_test_case_type(type) - 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): self._load_test_case_dir(type, dir) else: @@ -95,7 +96,7 @@ class TestSuite: del self.test_cases[m] 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'): self.correct_test_cases[test_case.type].add(basename(test_case.file)) -- GitLab