1#!/usr/bin/env python 2# Copyright 2014 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 argparse 7import json 8import os 9import sys 10 11# Add src/testing/ into sys.path for importing common without pylint errors. 12sys.path.append( 13 os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) 14from scripts import common 15 16 17def main(argv): 18 parser = argparse.ArgumentParser() 19 parser.add_argument('--output', required=True) 20 parser.add_argument('args', nargs=argparse.REMAINDER) 21 22 args = parser.parse_args(argv) 23 24 passthrough_args = args.args 25 if passthrough_args[0] == '--': 26 passthrough_args = passthrough_args[1:] 27 28 results = {} 29 30 for filename in os.listdir(common.SCRIPT_DIR): 31 if not filename.endswith('.py'): 32 continue 33 if filename in ('common.py', 34 'get_compile_targets.py', 35 'gpu_integration_test_adapter.py', 36 'PRESUBMIT.py', 37 'sizes_common.py', 38 'variations_seed_access_helper.py', 39 'run_variations_smoke_tests.py', 40 'run_performance_tests_unittest.py'): 41 continue 42 43 with common.temporary_file() as tempfile_path: 44 rc = common.run_command( 45 [sys.executable, os.path.join(common.SCRIPT_DIR, filename)] + 46 passthrough_args + 47 [ 48 'compile_targets', 49 '--output', tempfile_path 50 ] 51 ) 52 if rc != 0: 53 return rc 54 55 with open(tempfile_path) as f: 56 # json.load() throws a ValueError for empty files 57 try: 58 results[filename] = json.load(f) 59 except ValueError: 60 pass 61 62 with open(args.output, 'w') as f: 63 json.dump(results, f) 64 65 return 0 66 67 68if __name__ == '__main__': 69 sys.exit(main(sys.argv[1:])) 70