2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Runs isolate bundled Telemetry unittests.
8 This script attempts to emulate the contract of gtest-style tests
9 invoked via recipes. The main contract is that the caller passes the
12 --test-launcher-summary-output=[FILENAME]
14 json is written to that file in the format produced by
15 common.parse_common_test_results.
17 This script is intended to be the base command invoked by the isolate,
18 followed by a subsequent Python script. It could be generalized to
19 invoke an arbitrary executable.
32 parser
= argparse
.ArgumentParser()
34 '--test-launcher-summary-output',
35 type=argparse
.FileType('w'),
37 args
, rest_args
= parser
.parse_known_args()
38 with common
.temporary_file() as tempfile_path
:
39 rc
= common
.run_command([sys
.executable
] + rest_args
+ [
40 '--write-full-results-to', tempfile_path
,
42 with
open(tempfile_path
) as f
:
43 results
= json
.load(f
)
44 parsed_results
= common
.parse_common_test_results(results
,
46 failures
= parsed_results
['unexpected_failures']
49 'valid': bool(rc
<= common
.MAX_FAILURES_EXIT_STATUS
and
50 ((rc
== 0) or failures
)),
51 'failures': failures
.keys(),
52 }, args
.test_launcher_summary_output
)
57 # This is not really a "script test" so does not need to manually add
58 # any additional compile targets.
59 def main_compile_targets(args
):
60 json
.dump([], args
.output
)
63 if __name__
== '__main__':
64 # Conform minimally to the protocol defined by ScriptTest.
65 if 'compile_targets' in sys
.argv
:
68 'compile_targets': main_compile_targets
,
70 sys
.exit(common
.run_script(sys
.argv
[1:], funcs
))