예제 #1
0
def main(args):
    tests = get_tests(args.test_dir, args.test_list, args.skip_list)
    total = len(tests)
    if total == 0:
        print("No test to execute.")
        return 1

    if sys.platform == 'win32':
        original_timezone = util.get_timezone()
        util.set_sighdl_to_reset_timezone(original_timezone)
        util.set_timezone('UTC')

    if args.snapshot:
        passed = run_snapshot_tests(args, tests)
    else:
        passed = run_normal_tests(args, tests)

    if sys.platform == 'win32':
        util.set_timezone(original_timezone)

    failed = total - passed

    summary_list = [os.path.relpath(args.engine)]
    if args.snapshot:
        summary_list.append('--snapshot')
    if args.test_dir:
        summary_list.append(os.path.relpath(args.test_dir))
    if args.test_list:
        summary_list.append(os.path.relpath(args.test_list))
    util.print_test_summary(' '.join(summary_list), total, passed, failed)

    return bool(failed)
예제 #2
0
def main(args):
    util.setup_stdio()
    unittests = get_unittests(args.path)
    total = len(unittests)
    if total == 0:
        print("%s: no unit-* test to execute", args.path)
        return 1

    test_cmd = [args.runtime] if args.runtime else []

    tested = 0
    passed = 0
    failed = 0
    for test in unittests:
        tested += 1
        test_path = os.path.relpath(test)
        try:
            subprocess.check_output(test_cmd + [test],
                                    stderr=subprocess.STDOUT,
                                    universal_newlines=True)
            passed += 1
            if not args.quiet:
                util.print_test_result(tested, total, True, 'PASS', test_path)
        except subprocess.CalledProcessError as err:
            failed += 1
            util.print_test_result(tested, total, False,
                                   'FAIL (%d)' % err.returncode, test_path)
            print("================================================")
            print(err.output)
            print("================================================")

    util.print_test_summary(os.path.join(os.path.relpath(args.path), "unit-*"),
                            total, passed, failed)

    if failed > 0:
        return 1
    return 0