[Telemetry] Always uploading browser log if enabled instead of wait for crash to...
[chromium-blink-merge.git] / testing / scripts / telemetry_unittests.py
blobad7e66f1bfdd9583ad8d88853557fcc3a7ce8c4e
1 #!/usr/bin/env python
2 # Copyright 2014 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 import json
7 import os
8 import sys
11 import common
14 def main_run(args):
15 filter_tests = []
16 if args.filter_file:
17 filter_tests = json.load(args.filter_file)
19 with common.temporary_file() as tempfile_path:
20 rc = common.run_runtest(args, [
21 '--test-type', 'telemetry_unittests',
22 '--run-python-script',
23 os.path.join(common.SRC_DIR, 'tools', 'telemetry', 'run_tests'),
24 '--browser', args.build_config_fs.lower(),
25 '--retry-limit', '3',
26 '--write-full-results-to', tempfile_path,
27 ] + filter_tests)
29 with open(tempfile_path) as f:
30 results = json.load(f)
32 parsed_results = common.parse_common_test_results(results, test_separator='.')
33 failures = parsed_results['unexpected_failures']
35 json.dump({
36 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
37 ((rc == 0) or failures)),
38 'failures': failures.keys(),
39 }, args.output)
41 return rc
44 def main_compile_targets(args):
45 json.dump(['chrome'], args.output)
48 if __name__ == '__main__':
49 funcs = {
50 'run': main_run,
51 'compile_targets': main_compile_targets,
53 sys.exit(common.run_script(sys.argv[1:], funcs))