예제 #1
0
def process_args(args, error):
    """ Processes the given args, detecting errors. """
    if not args.run_all_tests and not args.demo and not args.test:
        args.list = True

    if args.run_all_tests:
        if args.test or args.demo:
            error("can't run individual test or demo when running all tests")

    if args.test and args.demo:
        error("can't run a demo _and_ tests")

    from openage.cppinterface.setup import setup
    setup()

    test_list = get_all_tests_and_demos()

    if args.run_all_tests:
        args.test = [name for name, type_ in test_list if type_ == 'test']

    for test in args.test:
        if not (test, 'test') in test_list:
            error("no such test: " + test)

    if args.demo:
        if not (args.demo[0], 'demo') in test_list:
            error("no such demo: " + args.demo[0])

    return test_list
예제 #2
0
파일: main.py 프로젝트: yuwuyi/openage
def process_args(args, error):
    """ Processes the given args, detecting errors. """
    if not args.run_all_tests and not args.demo and not args.test:
        args.list = True

    if args.run_all_tests:
        if args.test or args.demo:
            error("can't run individual test or demo when running all tests")

    if args.test and args.demo:
        error("can't run a demo _and_ tests")

    from openage.cppinterface.setup import setup

    setup()

    test_list = get_all_tests_and_demos()

    if args.run_all_tests:
        args.test = [name for name, type_ in test_list if type_ == "test"]

    for test in args.test:
        if not (test, "test") in test_list:
            error("no such test: " + test)

    if args.demo:
        if not (args.demo[0], "demo") in test_list:
            error("no such demo: " + args.demo[0])

    return test_list
예제 #3
0
def process_args(args, error):
    """ Processes the given args, detecting errors. """
    if not (args.run_all_tests or args.demo or args.test or args.benchmark):
        args.list = True

    if args.have_assets and not args.run_all_tests:
        error("you have to run all tests, "
              "otherwise I don't care if you have assets")

    if args.run_all_tests and (args.test or args.demo or args.benchmark):
        error("can't run individual test or demo or benchmark when running "
              "all tests")

    if bool(args.test) + bool(args.demo) + bool(args.benchmark) > 1:
        error("can only run one of demo, benchmarks or tests")

    # link python and c++ so it hopefully works when testing
    from openage.cppinterface.setup import setup
    setup(args)

    test_list = get_all_targets()

    # the current test environment can have influence on the tests itself.
    test_environment = {
        "has_assets": args.have_assets,
    }

    # if we wanna run all the tests, only run the ones that
    # are happy with the environment
    if args.run_all_tests:
        tests = [name for (name, test_type), (test_condition, _, _, _)
                 in test_list.items()
                 if test_type == "test" and test_condition(test_environment)]
        args.test.extend(tests)

    # double-check for unknown tests and demos, maybe we can match them
    for test in args.test:
        matched = False
        if (test, 'test') not in test_list:
            # If the test was not found explicit in the testlist, try to find
            # all prefixed tests and run them instead.
            matched = [elem[0] for elem in test_list
                       if elem[0].startswith(test) and elem[1] == "test"]

            if matched:
                args.test.extend(matched)
            else:
                error("no such test: " + test)
            args.test.remove(test)

    if args.demo and (args.demo[0], 'demo') not in test_list:
        error("no such demo: " + args.demo[0])

    if args.benchmark and (args.benchmark[0], 'benchmark') not in test_list:
        error("no such benchmark: " + args.benchmark[0])

    return test_list
예제 #4
0
def process_args(args, error):
    """ Processes the given args, detecting errors. """
    if not args.run_all_tests and not args.demo and not args.test:
        args.list = True

    if args.have_assets and not args.run_all_tests:
        error("you have to run all tests, "
              "otherwise I don't care if you have assets")

    if args.run_all_tests:
        if args.test or args.demo:
            error("can't run individual test or demo when running all tests")

    if args.test and args.demo:
        error("can't run a demo _and_ tests")

    # link python and c++ so it hopefully works when testing
    from openage.cppinterface.setup import setup
    setup()

    test_list = get_all_tests_and_demos()

    # the current test environment can have influence on the tests itself.
    test_environment = {
        "has_assets": args.have_assets,
    }

    # if we wanna run all the tests, only run the ones that
    # are happy with the environment
    if args.run_all_tests:
        for (name, test_type), (test_condition, _, _, _) in test_list.items():
            if test_type == "test" and test_condition(test_environment):
                args.test.append(name)

    # double-check for unknown tests and demos
    for test in args.test:
        if (test, 'test') not in test_list:
            error("no such test: " + test)

    if args.demo:
        if (args.demo[0], 'demo') not in test_list:
            error("no such demo: " + args.demo[0])

    return test_list