Mike Fleming | 3933d92 | 2018-04-02 10:53:08 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2017 the V8 project 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 | |
| 6 | """ |
| 7 | Legacy test-runner wrapper supporting a product of multiple architectures and |
| 8 | modes. |
| 9 | """ |
| 10 | |
| 11 | import argparse |
| 12 | import itertools |
| 13 | from os.path import abspath, dirname, join |
| 14 | import subprocess |
| 15 | import sys |
| 16 | |
| 17 | BASE_DIR = dirname(dirname(abspath(__file__))) |
| 18 | RUN_TESTS = join(BASE_DIR, 'tools', 'run-tests.py') |
| 19 | |
| 20 | def main(): |
| 21 | parser = argparse.ArgumentParser(description='Legacy test-runner wrapper') |
| 22 | parser.add_argument( |
| 23 | '--arch', help='Comma-separated architectures to run tests on') |
| 24 | parser.add_argument( |
| 25 | '--mode', help='Comma-separated modes to run tests on') |
| 26 | parser.add_argument( |
| 27 | '--arch-and-mode', |
| 28 | help='Architecture and mode in the format \'arch.mode\'', |
| 29 | ) |
| 30 | |
| 31 | args, remaining_args = parser.parse_known_args(sys.argv) |
| 32 | if (args.arch or args.mode) and args.arch_and_mode: |
| 33 | parser.error('The flags --arch-and-mode and --arch/--mode are exclusive.') |
| 34 | arch = (args.arch or 'ia32,x64,arm').split(',') |
| 35 | mode = (args.mode or 'release,debug').split(',') |
| 36 | if args.arch_and_mode: |
| 37 | arch_and_mode = map( |
| 38 | lambda am: am.split('.'), |
| 39 | args.arch_and_mode.split(',')) |
| 40 | arch = map(lambda am: am[0], arch_and_mode) |
| 41 | mode = map(lambda am: am[1], arch_and_mode) |
| 42 | |
| 43 | ret_code = 0 |
| 44 | for a, m in itertools.product(arch, mode): |
| 45 | ret_code |= subprocess.check_call( |
| 46 | [RUN_TESTS] + remaining_args[1:] + ['--arch', a, '--mode', m]) |
| 47 | return ret_code |
| 48 | |
| 49 | if __name__ == '__main__': |
| 50 | sys.exit(main()) |