Ejemplo n.º 1
0
    def run(self):
        """Run all the test target programs. """
        self._collect_test_jobs()
        tests_run_list = []
        for target_key in self.test_jobs:
            target = self.target_database[target_key]
            test_env = self._prepare_env(target)
            cmd = [os.path.abspath(self._executable(target))]
            cmd += self.options.args
            if console.color_enabled():
                test_env['GTEST_COLOR'] = 'yes'
            else:
                test_env['GTEST_COLOR'] = 'no'
            test_env['GTEST_OUTPUT'] = 'xml'
            test_env['HEAPCHECK'] = target.data.get('heap_check', '')
            pprof_path = config.get_item('cc_test_config', 'pprof_path')
            if pprof_path:
                test_env['PPROF_PATH'] = os.path.abspath(pprof_path)
            if self.options.coverage:
                test_env['BLADE_COVERAGE'] = 'true'
            tests_run_list.append(
                (target, self._runfiles_dir(target), test_env, cmd))

        console.notice('%d tests to run' % len(tests_run_list))
        console.flush()
        scheduler = TestScheduler(tests_run_list, self.options.test_jobs)
        try:
            scheduler.schedule_jobs()
        except KeyboardInterrupt:
            console.clear_progress_bar()
            console.error('KeyboardInterrupt, all tests stopped')
            console.flush()

        if self.options.coverage:
            self._generate_coverage_report()

        self._clean_env()

        passed_run_results, failed_run_results = scheduler.get_results()
        self._save_test_history(passed_run_results, failed_run_results)
        self._show_tests_result(passed_run_results, failed_run_results)

        return 0 if len(passed_run_results) == len(self.test_jobs) else 1
Ejemplo n.º 2
0
    def run(self):
        """Run all the test target programs. """
        self._collect_test_jobs()
        tests_run_list = []
        for target_key in self.test_jobs:
            target = self.target_database[target_key]
            test_env = self._prepare_env(target)
            cmd = [os.path.abspath(self._executable(target))]
            cmd += self.options.args
            if console.color_enabled():
                test_env['GTEST_COLOR'] = 'yes'
            else:
                test_env['GTEST_COLOR'] = 'no'
            test_env['GTEST_OUTPUT'] = 'xml'
            test_env['HEAPCHECK'] = target.data.get('heap_check', '')
            pprof_path = config.get_item('cc_test_config', 'pprof_path')
            if pprof_path:
                test_env['PPROF_PATH'] = os.path.abspath(pprof_path)
            if self.options.coverage:
                test_env['BLADE_COVERAGE'] = 'true'
            tests_run_list.append((target, self._runfiles_dir(target), test_env, cmd))

        console.notice('%d tests to run' % len(tests_run_list))
        sys.stdout.flush()
        scheduler = TestScheduler(tests_run_list, self.options.test_jobs)
        try:
            scheduler.schedule_jobs()
        except KeyboardInterrupt:
            console.clear_progress_bar()
            console.error('KeyboardInterrupt, all tests stopped')
            console.flush()

        if self.options.coverage:
            self._generate_coverage_report()

        self._clean_env()

        passed_run_results, failed_run_results = scheduler.get_results()
        self._save_test_history(passed_run_results, failed_run_results)
        self._show_tests_result(passed_run_results, failed_run_results)

        return 0 if len(passed_run_results) == len(self.test_jobs) else 1
Ejemplo n.º 3
0
def _show_progress(p, rf):
    # Convert description message such as '[1/123] CC xxx.cc' into progress bar
    progress_re = re.compile(r'^\[(\d+)/(\d+)\]\s+')
    try:
        while True:
            p.poll()
            line = rf.readline().strip()
            if line:
                m = progress_re.match(line)
                if m:
                    console.show_progress_bar(int(m.group(1)), int(m.group(2)))
                else:
                    console.clear_progress_bar()
                    console.output(line)
            elif p.returncode is not None:
                break
            else:
                # Avoid cost too much cpu
                time.sleep(0.1)
    finally:
        console.clear_progress_bar()
Ejemplo n.º 4
0
def _show_progress(p, rf):
    # Convert description message such as '[1/123] CC xxx.cc' into progress bar
    progress_re = re.compile(r'^\[(\d+)/(\d+)\]\s+')
    try:
        while True:
            p.poll()
            line = rf.readline().strip()
            if line:
                m = progress_re.match(line)
                if m:
                    console.show_progress_bar(int(m.group(1)), int(m.group(2)))
                else:
                    console.clear_progress_bar()
                    console.output(line)
            elif p.returncode is not None:
                break
            else:
                # Avoid cost too much cpu
                time.sleep(0.1)
    finally:
        console.clear_progress_bar()