Exemplo n.º 1
0
 def _print_artifacts(self):
     if self.artifacts:
         for file_type, artifact in self.artifacts:
             file_type_colored = red(
                 file_type) if artifact.error_priority else yellow(
                     file_type)
             print("  {} - {}".format(blue(artifact.file),
                                      file_type_colored),
                   flush=True)
Exemplo n.º 2
0
    def run(self):
        if self.skip:
            return True

        print(yellow("<" * curses.tigetnum("cols")), flush=True)
        print(yellow("Starting {}...".format(self.description)), flush=True)
        self.print_full_test_cmd()
        test_retcode = subprocess.call(self.get_cmd(), shell=True)
        if test_retcode:
            self.status = TestStatus.FAILED
            print(red("{} failed, please check.".format(self.description)), flush=True)
            print(red(">" * curses.tigetnum("cols")), flush=True)
        else:
            self.status = TestStatus.PASSED
            print(green("{} successfully finished!".format(self.description)), flush=True)
            print(green(">" * curses.tigetnum("cols")), flush=True)

        return not test_retcode
Exemplo n.º 3
0
    def __init__(self, status, test_file, artifacts, failed_stage):
        self.status = status
        self.test_file_path = test_file.file_path
        self.artifacts = None
        if artifacts is not None:
            self.artifacts = [(name, a) for name, a in artifacts.items() if a.error_priority >= 0]
            self.artifacts.sort(key=lambda x: x[1].error_priority, reverse=True)

        self.failed_stage_msg = None
        if failed_stage:
            self.failed_stage_msg = red("({})".format(failed_stage))
Exemplo n.º 4
0
def run_all_tests(tests_dir, jobs, test_tags, no_report, passed_list,
                  test_list, distcc_hosts):
    hack_reference_exit = []
    signal.signal(signal.SIGINT,
                  lambda sig, frame: hack_reference_exit.append(1))

    tests = collect_tests(tests_dir, test_tags, test_list)
    if not tests:
        print("Can't find any tests with [{}] {}".format(
            ", ".join(test_tags), "tag" if len(test_tags) == 1 else "tags"))
        sys.exit(1)

    results = []
    with ThreadPool(jobs) as pool:
        tests_completed = 0
        for test_result in pool.imap_unordered(partial(run_test, distcc_hosts),
                                               tests):
            if hack_reference_exit:
                print(yellow("Testing process was interrupted"), flush=True)
                break
            tests_completed = tests_completed + 1
            test_result.print_short_report(len(tests), tests_completed)
            results.append(test_result)

    print("\nTesting results:", flush=True)

    skipped = len(tests) - len(results)
    failed = 0
    passed = []
    for test_result in results:
        if test_result.is_skipped():
            skipped = skipped + 1
        elif test_result.is_failed():
            failed = failed + 1
        else:
            passed.append(
                os.path.relpath(test_result.test_file_path, tests_dir))

    if passed:
        print("  {}{}".format(green("passed:  "), len(passed)))
        if passed_list:
            with open(passed_list, "w") as f:
                passed.sort()
                f.writelines("{}\n".format(l) for l in passed)
    if skipped:
        print("  {}{}".format(yellow("skipped: "), skipped))
    if failed:
        print("  {}{}\n".format(red("failed:  "), failed))
        if not no_report:
            for test_result in results:
                test_result.print_fail_report()

    sys.exit(1 if failed else len(hack_reference_exit))
Exemplo n.º 5
0
class TestStatus(Enum):
    FAILED = red("failed")
    PASSED = green("passed")
    SKIPPED = yellow("skipped")
Exemplo n.º 6
0
    cxx_compiler = CC2CXX_MAP[cc_compiler]

    cmake_options = []
    env_vars = []
    if args.use_asan:
        cmake_options.append("-DADDRESS_SANITIZER=ON")
        env_vars.append("ASAN_OPTIONS=detect_leaks=0")
    if args.use_ubsan:
        cmake_options.append("-DUNDEFINED_SANITIZER=ON")
        env_vars.append("UBSAN_OPTIONS=print_stacktrace=1:allow_addr2line=1")
    cmake_options = " ".join(cmake_options)
    env_vars = " ".join(env_vars)

    kphp_polyfills_repo = args.kphp_polyfills_repo
    if kphp_polyfills_repo == "":
        print(red("empty --kphp-polyfills-repo argument"), flush=True)
    kphp_polyfills_repo = os.path.abspath(kphp_polyfills_repo)

    distcc_options = ""
    distcc_cmake_option = ""
    distcc_hosts_file = ""
    if args.use_distcc:
        distcc_hosts_file = "/etc/distcc/hosts"
        distcc_options = "--distcc-host-list {}".format(distcc_hosts_file)
        os.environ.update(
            make_distcc_env(read_distcc_hosts(distcc_hosts_file),
                            os.path.join(runner_dir, "tmp_distcc")))
        distcc_cmake_option = "-DCMAKE_CXX_COMPILER_LAUNCHER=distcc "

    runner.add_test_group(
        name="make-kphp",
Exemplo n.º 7
0
 def failed(test_file, artifacts, failed_stage):
     return TestResult(red("failed "), test_file, artifacts, failed_stage)