def export_testcases(self):
        vp.print("Copying test data...")
        try:
            test_name_list = tu.get_test_names_from_tests_dir(TESTS_DIR)
        except tu.MalformedTestsException as e:
            raise ExportFailureException(str(e))
        vp.print_var("test_name_list", test_name_list)
        available_tests, missing_tests = tu.divide_tests_by_availability(
            test_name_list, TESTS_DIR)
        if missing_tests:
            warn("Missing tests: " + (", ".join(missing_tests)))
        vp.print_var("available_tests", available_tests)

        self.create_directory(self.TESTS_DIR_NAME)
        for test_name in available_tests:
            clean_test_name = make_clean_name(test_name)
            self.copy_file(
                os.path.join(TESTS_DIR, "{}.in".format(test_name)),
                os.path.join(self.TESTS_DIR_NAME,
                             "{}.in".format(clean_test_name)),
            )
            self.copy_file(
                os.path.join(TESTS_DIR, "{}.out".format(test_name)),
                os.path.join(self.TESTS_DIR_NAME,
                             "{}.out".format(clean_test_name)))
Beispiel #2
0
from util import get_bool_environ, simple_usage_message, wait_process_success
from color_util import cprinterr, colors
import tests_util as tu

INTERNALS_DIR = os.environ.get('INTERNALS')
SPECIFIC_TESTS = get_bool_environ('SPECIFIC_TESTS')
SPECIFIED_TESTS_PATTERN = os.environ.get('SPECIFIED_TESTS_PATTERN')

if __name__ == '__main__':
    if len(sys.argv) != 2:
        simple_usage_message("<tests-dir>")
    tests_dir = sys.argv[1]

    try:
        test_name_list = tu.get_test_names_from_tests_dir(tests_dir)
    except tu.MalformedTestsException as e:
        cprinterr(colors.ERROR, "Error:")
        sys.stderr.write("{}\n".format(e))
        sys.exit(4)

    if SPECIFIC_TESTS:
        tu.check_pattern_exists_in_test_names(SPECIFIED_TESTS_PATTERN,
                                              test_name_list)
        test_name_list = tu.filter_test_names_by_pattern(
            test_name_list, SPECIFIED_TESTS_PATTERN)

    available_tests, missing_tests = tu.divide_tests_by_availability(
        test_name_list, tests_dir)
    if missing_tests:
        cprinterr(colors.WARN, "Missing tests: " + (", ".join(missing_tests)))