Replace dump_json_test_results flag by isolated-script-test-output.

This is because it's the default flag used in the recipes to dump a json output.
This CL also fixes some python3 lint issues in mb.py.

Bug: webrtc:13594
Change-Id: I9275b5da0963f801d3191703c2eb72d90befb5d7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/248142
Reviewed-by: Christoffer Jansson <jansson@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#35986}
This commit is contained in:
Jeremy Leconte
2022-02-11 13:46:02 +01:00
committed by WebRTC LUCI CQ
parent ea8dfd5011
commit 63472e5aea
4 changed files with 19 additions and 19 deletions

View File

@ -135,9 +135,11 @@ def ParseArgs(argv=None):
# These options will be passed unchanged to gtest-parallel.
gtest_group.AddArgument('-d', '--output_dir')
gtest_group.AddArgument('-r', '--repeat')
# TODO(webrtc:13556): use isolated-script-test-output argument instead
# of dump_json_test_results as it was done prior to chromium:1051927.
gtest_group.AddArgument('--dump_json_test_results')
# --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.
gtest_group.AddArgument('--isolated-script-test-output',
dest='dump_json_test_results')
gtest_group.AddArgument('--retry_failed')
gtest_group.AddArgument('--gtest_color')
gtest_group.AddArgument('--gtest_filter')

View File

@ -108,6 +108,12 @@ class GtestParallelWrapperTest(unittest.TestCase):
self.assertEqual(result.output_dir, '/tmp/foo')
self.assertEqual(result.test_artifacts_dir, None)
def testJsonTestResults(self):
result = gtest_parallel_wrapper.ParseArgs(
['--isolated-script-test-output', '/tmp/foo', 'exec'])
expected = self._Expected(['--dump_json_test_results=/tmp/foo', 'exec'])
self.assertEqual(result.gtest_parallel_args, expected)
def testShortArg(self):
result = gtest_parallel_wrapper.ParseArgs(['-d', '/tmp/foo', 'exec'])
expected = self._Expected(['--output_dir=/tmp/foo', 'exec'])
@ -131,13 +137,14 @@ class GtestParallelWrapperTest(unittest.TestCase):
result = gtest_parallel_wrapper.ParseArgs([
'some_test', '--some_flag=some_value', '--another_flag',
'--output_dir=' + output_dir, '--store-test-artifacts',
'--isolated-script-test-output=SOME_DIR',
'--isolated-script-test-perf-output=SOME_OTHER_DIR', '--foo=bar',
'--baz'
])
expected_artifacts_dir = os.path.join(output_dir, 'test_artifacts')
expected = self._Expected([
'--output_dir=' + output_dir, 'some_test', '--',
'--test_artifacts_dir=' + expected_artifacts_dir,
'--output_dir=' + output_dir, '--dump_json_test_results=SOME_DIR',
'some_test', '--', '--test_artifacts_dir=' + expected_artifacts_dir,
'--some_flag=some_value', '--another_flag',
'--isolated_script_test_perf_output=SOME_OTHER_DIR', '--foo=bar',
'--baz'

View File

@ -41,7 +41,7 @@ def main(args):
return mbw.Main(args)
class MetaBuildWrapper(object):
class MetaBuildWrapper:
def __init__(self):
self.src_dir = SRC_DIR
self.default_config = os.path.join(SCRIPT_DIR, 'mb_config.pyl')
@ -580,8 +580,8 @@ class MetaBuildWrapper(object):
try:
contents = ast.literal_eval(self.ReadFile(self.args.config_file))
except SyntaxError as e:
raise MBErr('Failed to parse config file "%s": %s' %
(self.args.config_file, e))
raise MBErr('Failed to parse config file "%s"' %
self.args.config_file) from e
self.configs = contents['configs']
self.builder_groups = contents['builder_groups']
@ -594,8 +594,7 @@ class MetaBuildWrapper(object):
try:
return ast.literal_eval(self.ReadFile(isolate_map))
except SyntaxError as e:
raise MBErr('Failed to parse isolate map file "%s": %s' %
(isolate_map, e))
raise MBErr('Failed to parse isolate map file "%s"' % isolate_map) from e
def ConfigFromArgs(self):
if self.args.config:
@ -962,12 +961,10 @@ class MetaBuildWrapper(object):
]
sep = '\\' if self.platform == 'win32' else '/'
output_dir = '${ISOLATED_OUTDIR}' + sep + 'test_logs'
test_results = '${ISOLATED_OUTDIR}' + sep + 'gtest_output.json'
timeout = isolate_map[target].get('timeout', 900)
cmdline += [
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=%s' % output_dir,
'--dump_json_test_results=%s' % test_results,
'--gtest_color=no',
# We tell gtest-parallel to interrupt the test after 900
# seconds, so it can exit cleanly and report results,
@ -1151,7 +1148,7 @@ class MetaBuildWrapper(object):
json.dumps(obj, indent=2, sort_keys=True) + '\n',
force_verbose=force_verbose)
except Exception as e:
raise MBErr('Error %s writing to the output path "%s"' % (e, path))
raise MBErr('Error writing to the output path "%s"' % path) from e
def PrintCmd(self, cmd, env):
if self.platform == 'win32':

View File

@ -440,7 +440,6 @@ class UnitTest(unittest.TestCase):
'../../testing/test_env.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}/gtest_output.json',
'--gtest_color=no',
'--timeout=500',
'--workers=1',
@ -570,7 +569,6 @@ class UnitTest(unittest.TestCase):
'../../testing/test_env.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}/gtest_output.json',
'--gtest_color=no',
'--timeout=900',
'--workers=1',
@ -623,7 +621,6 @@ class UnitTest(unittest.TestCase):
'../../testing/xvfb.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}/gtest_output.json',
'--gtest_color=no',
'--timeout=900',
'--retry_failed=3',
@ -676,7 +673,6 @@ class UnitTest(unittest.TestCase):
'../../testing/test_env.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}\\test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}\\gtest_output.json',
'--gtest_color=no',
'--timeout=900',
'--retry_failed=3',
@ -725,7 +721,6 @@ class UnitTest(unittest.TestCase):
'../../testing/test_env.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}/gtest_output.json',
'--gtest_color=no',
'--timeout=900',
'--retry_failed=3',
@ -780,7 +775,6 @@ class UnitTest(unittest.TestCase):
'../../testing/test_env.py',
'../../tools_webrtc/gtest-parallel-wrapper.py',
'--output_dir=${ISOLATED_OUTDIR}/test_logs',
'--dump_json_test_results=${ISOLATED_OUTDIR}/gtest_output.json',
'--gtest_color=no',
'--timeout=900',
'--retry_failed=3',