Beispiel #1
0
def _main():
    if len(sys.argv) != 3:
        simple_usage_message("<gen-data-file> <tests-dir>")
    gen_data_file = sys.argv[1]
    tests_dir = sys.argv[2]

    task_data = load_json(PROBLEM_JSON)
    with open(gen_data_file, 'r') as gdf:
        gen_data = gdf.readlines()

    if SPECIFIC_TESTS:
        tu.check_pattern_exists_in_test_names(
            SPECIFIED_TESTS_PATTERN,
            tu.get_test_names_by_gen_data(gen_data, task_data))

    summary_visitor = SummaryVisitor()
    parse_data(gen_data, task_data, summary_visitor)
    summary_visitor.make_gen_summary_file(tests_dir)

    mapping_visitor = MappingVisitor()
    parse_data(gen_data, task_data, mapping_visitor)
    mapping_visitor.make_mapping_file(tests_dir)

    parse_data(gen_data, task_data, GeneratingVisitor(tests_dir))
Beispiel #2
0

if __name__ == '__main__':
    
    if len(sys.argv) != 4:
        from util import simple_usage_message
        simple_usage_message("<tests-dir> <mapping-file> <gen-summary-file>")
    
    global tests_dir
    tests_dir = sys.argv[1]
    mapping_file = sys.argv[2]
    gen_summary_file = sys.argv[3]
    
    task_data = load_json(PROBLEM_JSON)
    gen_data = sys.stdin.readlines()

    if SPECIFIC_TESTS == "true":
        check_test_pattern_exists(gen_data, task_data, SPECIFIED_TESTS_PATTERN)

    summary_visitor = SummaryVisitor()
    parse_data(gen_data, task_data, summary_visitor)
    with open(gen_summary_file, 'w') as f:
        summary_visitor.print_summary(f)
    
    mapping_visitor = MappingVisitor()
    parse_data(gen_data, task_data, mapping_visitor)
    with open(mapping_file, 'w') as f:
        mapping_visitor.print_mapping(f)

    parse_data(gen_data, task_data, GeneratingVisitor())
Beispiel #3
0
        for subtask in self.subtasks:
            for test in sorted(list(self.tests_map[subtask])):
                stream.write("%s %s\n" % (subtask, test))


class GeneratingVisitor(DataVisitor):
    def on_test(self, testset_name, test_name, line):
        if SINGULAR_TEST == "false" or test_name == SOLE_TEST_NAME:
            command = [
                'bash',
                os.path.join(INTERNALS_DIR, 'gen_test.sh'),
                test_name,
                line.strip('\n'),
            ]
            run_bash_command(command)


if __name__ == '__main__':
    gen_data = sys.stdin.readlines()

    if SINGULAR_TEST == "true":
        check_test_exists(gen_data, SOLE_TEST_NAME)

    mapping_visitor = MappingVisitor()
    parse_data(gen_data, mapping_visitor)

    with open(sys.argv[1], 'w') as f:
        mapping_visitor.print_mapping(f)

    parse_data(gen_data, GeneratingVisitor())
Beispiel #4
0
import os
import sys

from gen_data_parser import DataVisitor, parse_data, check_test_exists
from util import run_bash_command

INTERNALS_DIR = os.environ.get('INTERNALS')
SINGULAR_TEST = os.environ.get('SINGULAR_TEST')
SOLE_TEST_NAME = os.environ.get('SOLE_TEST_NAME')


class InvokingVisitor(DataVisitor):
    def on_test(self, testset_name, test_name, line):
        if SINGULAR_TEST == "false" or test_name == SOLE_TEST_NAME:
            command = [
                'bash',
                os.path.join(INTERNALS_DIR, 'invoke_test.sh'),
                test_name,
            ]
            run_bash_command(command)


if __name__ == '__main__':
    gen_data = sys.stdin.readlines()

    if SINGULAR_TEST == "true":
        check_test_exists(gen_data, SOLE_TEST_NAME)

    parse_data(gen_data, InvokingVisitor())
Beispiel #5
0
def get_test_names_by_gen_data(gen_data, task_data):
    tests_visitor = TestsVisitor()
    parse_data(gen_data, task_data, tests_visitor)
    return tests_visitor.tests