blob: cb0bb375681a64a1c299d412bc3f4fde66e456e3 [file] [log] [blame]
Takuto Ikutad0a8c002022-07-01 01:56:591#!/usr/bin/env vpython3
skyostil1ec102e2016-10-13 03:11:362# Copyright 2016 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.
5
6import json
7import os
8import sys
9
Joshua Hood3fade1f2022-05-04 16:00:4210# Add src/testing/ into sys.path for importing common without pylint errors.
11sys.path.append(
12 os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
13from scripts import common
skyostil1ec102e2016-10-13 03:11:3614
15
16def main_run(args):
17 typ_path = os.path.abspath(os.path.join(
18 os.path.dirname(__file__), os.path.pardir, os.path.pardir,
Ned Nguyenc335c432018-04-23 01:16:4619 'third_party', 'catapult', 'third_party', 'typ'))
skyostil1ec102e2016-10-13 03:11:3620 _AddToPathIfNeeded(typ_path)
Joshua Hood3fade1f2022-05-04 16:00:4221 import typ #pylint: disable=import-outside-toplevel
skyostil1ec102e2016-10-13 03:11:3622
altimineaffa8e02016-11-08 23:56:3123 top_level_dir = os.path.join(
24 common.SRC_DIR, 'headless', 'lib', 'browser', 'devtools_api')
skyostil1ec102e2016-10-13 03:11:3625 with common.temporary_file() as tempfile_path:
26 rc = typ.main(
27 argv=[],
28 top_level_dir=top_level_dir,
29 write_full_results_to=tempfile_path,
30 coverage_source=[top_level_dir])
31
32 with open(tempfile_path) as f:
33 results = json.load(f)
34
35 parsed_results = common.parse_common_test_results(results, test_separator='.')
36 failures = parsed_results['unexpected_failures']
37
Ben Pastene58c7818f2021-07-01 16:58:0738 valid = bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
39 ((rc == 0) or failures))
40 common.record_local_script_results(
Takuto Ikutad0a8c002022-07-01 01:56:5941 'headless_python_unittests', args.output, list(failures.keys()), valid)
skyostil1ec102e2016-10-13 03:11:3642
43 return rc
44
45
46def main_compile_targets(args):
47 json.dump([], args.output)
48
49
50def _AddToPathIfNeeded(path):
51 if path not in sys.path:
52 sys.path.insert(0, path)
53
54
55if __name__ == '__main__':
56 funcs = {
57 'run': main_run,
58 'compile_targets': main_compile_targets,
59 }
60 sys.exit(common.run_script(sys.argv[1:], funcs))