• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2015 The Chromium Authors
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
10# 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
14
15
16def main_run(args):
17  with common.temporary_file() as tempfile_path:
18    rc = common.run_command([
19        sys.executable,
20        os.path.join(common.SRC_DIR, 'third_party', 'blink',
21                     'tools', 'run_blinkpy_tests.py'),
22        '--write-full-results-to', tempfile_path,
23    ], cwd=args.paths['checkout'])
24
25    with open(tempfile_path) as f:
26      results = json.load(f)
27
28  parsed_results = common.parse_common_test_results(results)
29  failures = parsed_results['unexpected_failures']
30
31  json.dump({
32      'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
33                   ((rc == 0) or failures)),
34      'failures': failures.keys(),
35  }, args.output)
36
37  return rc
38
39
40def main_compile_targets(args):
41  json.dump([], args.output)
42
43
44if __name__ == '__main__':
45  funcs = {
46    'run': main_run,
47    'compile_targets': main_compile_targets,
48  }
49  sys.exit(common.run_script(sys.argv[1:], funcs))
50