mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 14:20:45 +01:00
Revert of flag simplification.
In order to unify WebRTC recipes with Chromium recipes this CL tries to revert the old CL https://webrtc-review.googlesource.com/c/src/+/171681. This CL was already partially reverted (https://webrtc-review.googlesource.com/c/src/+/171809). In upcoming CLs, the added flag dump_json_test_results will be removed in order to use isolated-script-test-output instead. Bug: webrtc:13556 Change-Id: I3144498b9a5cbaa56c23b3b8adbac2229ad63c37 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245602 Reviewed-by: Andrey Logvin <landrey@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Cr-Commit-Position: refs/heads/main@{#35666}
This commit is contained in:
parent
ba38934771
commit
994bf454ec
4 changed files with 173 additions and 145 deletions
|
@ -15,6 +15,7 @@ output files will be performed.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import collections
|
import collections
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -62,6 +63,10 @@ def _ParseArgs():
|
||||||
'--isolated-script-test-perf-output',
|
'--isolated-script-test-perf-output',
|
||||||
default=None,
|
default=None,
|
||||||
help='Path to store perf results in histogram proto format.')
|
help='Path to store perf results in histogram proto format.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--isolated-script-test-output',
|
||||||
|
default=None,
|
||||||
|
help='Path to output an empty JSON file which Chromium infra requires.')
|
||||||
parser.add_argument('--extra-test-args',
|
parser.add_argument('--extra-test-args',
|
||||||
default=[],
|
default=[],
|
||||||
action='append',
|
action='append',
|
||||||
|
@ -262,7 +267,6 @@ def _ConfigurePythonPath(args):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# pylint: disable=W0101
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logging.info('Invoked with %s', str(sys.argv))
|
logging.info('Invoked with %s', str(sys.argv))
|
||||||
|
|
||||||
|
@ -354,6 +358,10 @@ def main():
|
||||||
with open(args.isolated_script_test_perf_output, 'wb') as f:
|
with open(args.isolated_script_test_perf_output, 'wb') as f:
|
||||||
f.write(histograms.AsProto().SerializeToString())
|
f.write(histograms.AsProto().SerializeToString())
|
||||||
|
|
||||||
|
if args.isolated_script_test_output:
|
||||||
|
with open(args.isolated_script_test_output, 'w') as f:
|
||||||
|
json.dump({"version": 3}, f)
|
||||||
|
|
||||||
return test_process.wait()
|
return test_process.wait()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,11 @@ ABSL_FLAG(
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
ABSL_FLAG(std::string,
|
||||||
|
isolated_script_test_output,
|
||||||
|
"",
|
||||||
|
"Path to output an empty JSON file which Chromium infra requires.");
|
||||||
|
|
||||||
ABSL_FLAG(
|
ABSL_FLAG(
|
||||||
std::string,
|
std::string,
|
||||||
isolated_script_test_perf_output,
|
isolated_script_test_perf_output,
|
||||||
|
@ -232,6 +237,14 @@ class TestMainImpl : public TestMain {
|
||||||
if (metrics_to_plot) {
|
if (metrics_to_plot) {
|
||||||
webrtc::test::PrintPlottableResults(*metrics_to_plot);
|
webrtc::test::PrintPlottableResults(*metrics_to_plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string result_filename =
|
||||||
|
absl::GetFlag(FLAGS_isolated_script_test_output);
|
||||||
|
if (!result_filename.empty()) {
|
||||||
|
std::ofstream result_file(result_filename);
|
||||||
|
result_file << "{\"version\": 3}";
|
||||||
|
result_file.close();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (capture_events) {
|
if (capture_events) {
|
||||||
|
|
|
@ -16,10 +16,15 @@ import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--isolated-script-test-output')
|
||||||
parser.add_argument('--isolated-script-test-perf-output')
|
parser.add_argument('--isolated-script-test-perf-output')
|
||||||
args, unrecognized_args = parser.parse_known_args()
|
args, unrecognized_args = parser.parse_known_args()
|
||||||
|
|
||||||
test_command = _ForcePythonInterpreter(unrecognized_args)
|
test_command = _ForcePythonInterpreter(unrecognized_args)
|
||||||
|
if args.isolated_script_test_output:
|
||||||
|
test_command += [
|
||||||
|
'--isolated_script_test_output', args.isolated_script_test_output
|
||||||
|
]
|
||||||
if args.isolated_script_test_perf_output:
|
if args.isolated_script_test_perf_output:
|
||||||
test_command += [
|
test_command += [
|
||||||
'--isolated_script_test_perf_output=' +
|
'--isolated_script_test_perf_output=' +
|
||||||
|
@ -41,6 +46,5 @@ def _ForcePythonInterpreter(cmd):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# pylint: disable=W0101
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
@ -15,7 +15,8 @@ gtest-parallel, renaming options and translating environment variables into
|
||||||
flags. Developers should execute gtest-parallel directly.
|
flags. Developers should execute gtest-parallel directly.
|
||||||
|
|
||||||
In particular, this translates the GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS
|
In particular, this translates the GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS
|
||||||
environment variables to the --shard_index and --shard_count flags
|
environment variables to the --shard_index and --shard_count flags, renames
|
||||||
|
the --isolated-script-test-output flag to --dump_json_test_results,
|
||||||
and interprets e.g. --workers=2x as 2 workers per core.
|
and interprets e.g. --workers=2x as 2 workers per core.
|
||||||
|
|
||||||
Flags before '--' will be attempted to be understood as arguments to
|
Flags before '--' will be attempted to be understood as arguments to
|
||||||
|
@ -44,6 +45,7 @@ For example:
|
||||||
--another_flag \
|
--another_flag \
|
||||||
--output_dir=SOME_OUTPUT_DIR \
|
--output_dir=SOME_OUTPUT_DIR \
|
||||||
--store-test-artifacts
|
--store-test-artifacts
|
||||||
|
--isolated-script-test-output=SOME_DIR \
|
||||||
--isolated-script-test-perf-output=SOME_OTHER_DIR \
|
--isolated-script-test-perf-output=SOME_OTHER_DIR \
|
||||||
-- \
|
-- \
|
||||||
--foo=bar \
|
--foo=bar \
|
||||||
|
@ -133,6 +135,8 @@ def ParseArgs(argv=None):
|
||||||
# These options will be passed unchanged to gtest-parallel.
|
# These options will be passed unchanged to gtest-parallel.
|
||||||
gtest_group.AddArgument('-d', '--output_dir')
|
gtest_group.AddArgument('-d', '--output_dir')
|
||||||
gtest_group.AddArgument('-r', '--repeat')
|
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')
|
gtest_group.AddArgument('--dump_json_test_results')
|
||||||
gtest_group.AddArgument('--retry_failed')
|
gtest_group.AddArgument('--retry_failed')
|
||||||
gtest_group.AddArgument('--gtest_color')
|
gtest_group.AddArgument('--gtest_color')
|
||||||
|
@ -160,13 +164,16 @@ def ParseArgs(argv=None):
|
||||||
|
|
||||||
options, unrecognized_args = parser.parse_known_args(argv)
|
options, unrecognized_args = parser.parse_known_args(argv)
|
||||||
|
|
||||||
|
webrtc_flags_to_change = {
|
||||||
|
'--isolated-script-test-perf-output':
|
||||||
|
'--isolated_script_test_perf_output',
|
||||||
|
'--isolated-script-test-output': '--isolated_script_test_output',
|
||||||
|
}
|
||||||
args_to_pass = []
|
args_to_pass = []
|
||||||
for arg in unrecognized_args:
|
for arg in unrecognized_args:
|
||||||
if arg.startswith('--isolated-script-test-perf-output'):
|
if any(arg.startswith(k) for k in webrtc_flags_to_change.keys()):
|
||||||
arg_split = arg.split('=')
|
arg_split = arg.split('=')
|
||||||
assert len(
|
args_to_pass.append(webrtc_flags_to_change[arg_split[0]] + '=' +
|
||||||
arg_split) == 2, 'You must use the = syntax for this flag.'
|
|
||||||
args_to_pass.append('--isolated_script_test_perf_output=' +
|
|
||||||
arg_split[1])
|
arg_split[1])
|
||||||
else:
|
else:
|
||||||
args_to_pass.append(arg)
|
args_to_pass.append(arg)
|
||||||
|
@ -178,8 +185,7 @@ def ParseArgs(argv=None):
|
||||||
'--output_dir must be specified for storing test artifacts.')
|
'--output_dir must be specified for storing test artifacts.')
|
||||||
test_artifacts_dir = os.path.join(options.output_dir, 'test_artifacts')
|
test_artifacts_dir = os.path.join(options.output_dir, 'test_artifacts')
|
||||||
|
|
||||||
executable_args.insert(0,
|
executable_args.insert(0, '--test_artifacts_dir=%s' % test_artifacts_dir)
|
||||||
'--test_artifacts_dir=%s' % test_artifacts_dir)
|
|
||||||
else:
|
else:
|
||||||
test_artifacts_dir = None
|
test_artifacts_dir = None
|
||||||
|
|
||||||
|
@ -227,13 +233,10 @@ def main():
|
||||||
|
|
||||||
if output_dir:
|
if output_dir:
|
||||||
for test_status in 'passed', 'failed', 'interrupted':
|
for test_status in 'passed', 'failed', 'interrupted':
|
||||||
logs_dir = os.path.join(output_dir, 'gtest-parallel-logs',
|
logs_dir = os.path.join(output_dir, 'gtest-parallel-logs', test_status)
|
||||||
test_status)
|
|
||||||
if not os.path.isdir(logs_dir):
|
if not os.path.isdir(logs_dir):
|
||||||
continue
|
continue
|
||||||
logs = [
|
logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)]
|
||||||
os.path.join(logs_dir, log) for log in os.listdir(logs_dir)
|
|
||||||
]
|
|
||||||
log_file = os.path.join(output_dir, '%s-tests.log' % test_status)
|
log_file = os.path.join(output_dir, '%s-tests.log' % test_status)
|
||||||
_CatFiles(logs, log_file)
|
_CatFiles(logs, log_file)
|
||||||
os.rmdir(logs_dir)
|
os.rmdir(logs_dir)
|
||||||
|
|
Loading…
Reference in a new issue