blob: 09e3f234fd1fb68836ce4f5049807e475560e85d [file] [log] [blame]
Viet-Trung Luu235cf3d2015-06-11 10:01:25 -07001#!/usr/bin/env python
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.
5
6import json
7import os
8import sys
9
10
11import common
12
13
14def main_run(args):
15 runner = os.path.join(common.SRC_DIR, 'mojo', 'tools', 'apptest_runner.py')
16 tests = os.path.join(common.SRC_DIR, 'mojo', 'tools', 'data', 'apptests')
17 build_dir = os.path.join(common.SRC_DIR, 'out', args.build_config_fs)
18
19 with common.temporary_file() as tempfile_path:
20 rc = common.run_command([runner, tests, build_dir, '--verbose',
21 '--write-full-results-to', tempfile_path])
22 with open(tempfile_path) as f:
23 results = json.load(f)
24
25 parsed_results = common.parse_common_test_results(results, test_separator='.')
26 failures = parsed_results['unexpected_failures']
27
28 json.dump({
29 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
30 ((rc == 0) or failures)),
31 'failures': failures.keys(),
32 }, args.output)
33
34 return rc
35
36
37def main_compile_targets(args):
38 json.dump(['mandoline:tests'], args.output)
39
40
41if __name__ == '__main__':
42 funcs = {
43 'run': main_run,
44 'compile_targets': main_compile_targets,
45 }
46 sys.exit(common.run_script(sys.argv[1:], funcs))