Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: third_party/gtest-parallel/gtest-parallel-wrapper.py

Issue 2558783002: Translate isolated-script-test-output to dump_json_test_results in gtest-parallel-wrapper.py (Closed)
Patch Set: Made sure it works. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gtest-parallel/gtest-parallel-wrapper.py
diff --git a/third_party/gtest-parallel/gtest-parallel-wrapper.py b/third_party/gtest-parallel/gtest-parallel-wrapper.py
index 1d8bcac71323fcf2572861cc5e24e5d8b9709d3d..1884ba04e70123c301ee27a2a24775891908e3af 100755
--- a/third_party/gtest-parallel/gtest-parallel-wrapper.py
+++ b/third_party/gtest-parallel/gtest-parallel-wrapper.py
@@ -8,6 +8,36 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
+"""
+This script acts as an interface between the Chromium infrastructure and
+gtest-parallel, renaming options and translating environment variables into
+flags. Developers should execute gtest-parallel directly.
+
+In particular, this translates the GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS
+environment variables to the --shard_index and --shard_count flags, and renames
+the --isolated-script-test-output flag to --dump_json_test_results.
+
+Note that the flags unprocessed by this script will passed as arguments to the
+test executable, i.e.
+
+ gtest-parallel-wrapper.py some_test \
+ --isolated-script-test-output=some_dir \
+ --unprocessed_arg_1
+ -- \
+ --unprocessed_arg_2
+
+will be converted into
+
+ python gtest-parallel some_test \
+ --shard_count 1 \
+ --shard_index 0 \
+ --dump_json_test_results some_dir \
+ -- \
+ --unprocessed_arg_1
+ --unprocessed_arg_2
+"""
+
+import argparse
import os
import subprocess
import sys
@@ -22,14 +52,39 @@ gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1')
gtest_parallel_path = os.path.dirname(os.path.abspath(__file__))
gtest_parallel_path = os.path.join(gtest_parallel_path, 'gtest-parallel')
-command = [
- sys.executable,
- gtest_parallel_path,
+# Ignore '--'. Options unprocessed by this script will be passed to the test as
+# arguments.
+if '--' in sys.argv:
+ del sys.argv[sys.argv.index('--')]
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--isolated-script-test-output', type=str, default=None)
+
+options, unprocessed = parser.parse_known_args()
+test_executable = unprocessed[0]
+test_arguments = unprocessed[1:]
+
+gtest_args = [
+ test_executable,
'--shard_count',
gtest_total_shards,
'--shard_index',
gtest_shard_index,
-] + sys.argv[1:]
+]
+
+# --isolated-script-test-output is used to upload results to the flakiness
+# dashboard. This translation is made because gtest-parallel expects the flag to
+# be called --dump_json_test_results instead.
+if options.isolated_script_test_output:
+ gtest_args += [
+ '--dump_json_test_results',
+ options.isolated_script_test_output,
+ ]
+
+command = [
+ sys.executable,
+ gtest_parallel_path,
+] + gtest_args + ['--'] + test_arguments
print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command)
sys.stdout.flush()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698