Support skia gold without parallel This adds the option of running skia tests one by one or in parallel. pdfium recipe is currently not passing in the --run-skia-gold flag, so this CL will not change any build behavior. Bug: pdfium:1642 Change-Id: I7550a29aa0052a156d1a715c954021b5ea2e199d Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/78370 Reviewed-by: Hui Yingst <nigi@chromium.org> Commit-Queue: Stephanie Kim <kimstephanie@google.com>
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py index 77ac19f..2b5ba1e 100644 --- a/testing/tools/test_runner.py +++ b/testing/tools/test_runner.py
@@ -300,6 +300,13 @@ default=False, help='When flag is on, skia gold tests will be run.') + parser.add_argument( + '--run-skia-gold-parallel', + action='store_true', + default=False, + help='When flag is on, skia gold tests will be run in parallel with ' + '--num_workers amount of processes.') + # TODO: Remove when pdfium recipe stops passing this argument parser.add_argument( '--gold_properties', @@ -417,13 +424,17 @@ self.result_suppressed_cases = [] gold_results = [] + if self.test_type not in TEXT_TESTS: + # Clear out and create top level gold output directory before starting + skia_gold.clear_gold_output_dir(self.options.gold_output_dir) + if self.options.num_workers > 1 and len(self.test_cases) > 1: try: pool = multiprocessing.Pool(self.options.num_workers) worker_func = functools.partial(TestOneFileParallel, self) worker_results = pool.imap(worker_func, self.test_cases) - skia_gold_inputs = [] + skia_gold_parallel_inputs = [] for worker_result in worker_results: result, input_filename, source_dir = worker_result input_path = os.path.join(source_dir, input_filename) @@ -433,16 +444,19 @@ if self.test_type not in TEXT_TESTS and self.options.run_skia_gold: _, image_paths = result if image_paths: - path_filename_tuples = [ - (path, input_filename) for path, _ in image_paths - ] - skia_gold_inputs.extend(path_filename_tuples) + if self.options.run_skia_gold_parallel: + path_filename_tuples = [ + (path, input_filename) for path, _ in image_paths + ] + skia_gold_parallel_inputs.extend(path_filename_tuples) + else: + for img_path, _ in image_paths: + test_name, skia_success = self.RunSkia(img_path) + gold_results.append((test_name, skia_success, input_filename)) - if skia_gold_inputs and self.test_type not in TEXT_TESTS: + if skia_gold_parallel_inputs: gold_worker_func = functools.partial(RunSkiaWrapper, self) - # Clear out top level gold output directory before starting - skia_gold.clear_gold_output_dir(self.options.gold_output_dir) - gold_results = pool.imap(gold_worker_func, skia_gold_inputs) + gold_results = pool.imap(gold_worker_func, skia_gold_parallel_inputs) except KeyboardInterrupt: pool.terminate() @@ -457,9 +471,8 @@ os.path.join(input_file_dir, input_filename), result) _, image_paths = result - if image_paths and self.test_type not in TEXT_TESTS: - # Clear out top level gold output directory before starting - skia_gold.clear_gold_output_dir(self.options.gold_output_dir) + if image_paths and self.test_type not in TEXT_TESTS and \ + self.options.run_skia_gold: for img_path, _ in image_paths: test_name, skia_success = self.RunSkia(img_path) gold_results.append((test_name, skia_success, input_filename)) @@ -517,7 +530,7 @@ print(' Suppressed:', number_suppressed) print(' Surprises:', number_surprises) print(' Failures:', number_failures) - if self.test_type not in TEXT_TESTS: + if self.test_type not in TEXT_TESTS and self.options.run_skia_gold: number_gold_failures = len(self.skia_gold_failures) number_gold_successes = len(self.skia_gold_successes) number_gold_surprises = len(self.skia_gold_unexpected_successes)