def main(): """CLI frontend to validate arguments.""" run_isolated.disable_buffering() parser = run_test_cases.OptionParserWithTestShardingAndFiltering( usage='%prog <options> [gtest]') # Override default seed value to default to 0. parser.set_defaults(seed=0) options, args = parser.parse_args() if not args: parser.error('Please provide the executable to run') cmd = run_isolated.fix_python_path(args) try: tests = run_test_cases.chromium_list_test_cases( cmd, os.getcwd(), index=options.index, shards=options.shards, seed=options.seed, disabled=options.disabled, fails=options.fails, flaky=options.flaky, pre=False, manual=options.manual) for test in tests: print test except run_test_cases.Failure, e: print e.args[0] return e.args[1]
def main(): parser = run_test_cases.OptionParserTestCases( usage='%prog <options> -s <something.isolated>') parser.add_option( '-s', '--isolated', help='The isolated file') options, args = parser.parse_args() if args: parser.error('Unsupported arg: %s' % args) if not options.isolated: parser.error('--isolated is required') if not options.isolated.endswith('.isolated'): parser.error('--isolated argument must end with .isolated') # Retrieve the command from the .isolated file. with open(options.isolated) as f: data = run_isolated.load_isolated(f.read()) if 'includes' in data: parser.error('includes key is not supported yet') command = data.get('command') if not command: parser.error('A command must be defined') test_cases = parser.process_gtest_options( run_isolated.fix_python_path(command), data.get('relative_cwd', os.getcwd()), options) if not test_cases: print >> sys.stderr, 'No test case to run' return 1 return not fix_all(options.isolated, test_cases)
def main(): """CLI frontend to validate arguments.""" run_isolated.disable_buffering() parser = run_test_cases.OptionParserTestCases( usage='%prog <options> [gtest]') parser.format_description = lambda *_: parser.description parser.add_option( '-o', '--out', help='output file, defaults to <executable>.test_cases') parser.add_option( '-r', '--root-dir', help='Root directory under which file access should be noted') parser.add_option( '--trace-blacklist', action='append', default=[], help='List of regexp to use as blacklist filter') # TODO(maruel): Add support for options.timeout. parser.remove_option('--timeout') options, args = parser.parse_args() if not args: parser.error( 'Please provide the executable line to run, if you need fancy things ' 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' '.') cmd = run_isolated.fix_python_path(args) cmd[0] = os.path.abspath(cmd[0]) if not os.path.isfile(cmd[0]): parser.error('Tracing failed for: %s\nIt doesn\'t exit' % ' '.join(cmd)) if not options.out: options.out = '%s.test_cases' % cmd[-1] options.out = os.path.abspath(options.out) if options.root_dir: options.root_dir = os.path.abspath(options.root_dir) logname = options.out + '.log' test_cases = parser.process_gtest_options(cmd, os.getcwd(), options) # Then run them. print('Tracing...') results = trace_test_cases( cmd, os.getcwd(), test_cases, options.jobs, logname) print('Reading trace logs...') blacklist = trace_inputs.gen_blacklist(options.trace_blacklist) write_details(logname, options.out, options.root_dir, blacklist, results) return 0
def safely_load_isolated(parser, options): """Loads a .isolated.state to extract the executable information. Returns the CompleteState instance, the command and the list of test cases. """ config = isolate.CompleteState.load_files(options.isolated) logging.debug( 'root_dir: %s relative_cwd: %s isolated: %s', config.root_dir, config.saved_state.relative_cwd, options.isolated) reldir = os.path.join(config.root_dir, config.saved_state.relative_cwd) command = config.saved_state.command test_cases = [] if command: command = run_isolated.fix_python_path(command) test_xvfb(command, reldir) test_cases = parser.process_gtest_options(command, reldir, options) return config, command, test_cases
def test_xvfb(command, rel_dir): """Calls back ourself if not running inside Xvfb and it's on the command line to run. Otherwise the X session will die while trying to start too many Xvfb instances. """ if os.environ.get('_CHROMIUM_INSIDE_XVFB') == '1': return for index, item in enumerate(command): if item.endswith('xvfb.py'): # Note this has inside knowledge about src/testing/xvfb.py. print('Restarting itself under Xvfb') prefix = command[index:index+2] prefix[0] = os.path.normpath(os.path.join(rel_dir, prefix[0])) prefix[1] = os.path.normpath(os.path.join(rel_dir, prefix[1])) cmd = run_isolated.fix_python_path(prefix + sys.argv) sys.exit(subprocess.call(cmd))
def main(): run_isolated.disable_buffering() parser = optparse.OptionParser(usage='%prog <options> [gtest]') parser.disable_interspersed_args() parser.add_option( '-I', '--index', type='int', default=os.environ.get('GTEST_SHARD_INDEX'), help='Shard index to run') parser.add_option( '-S', '--shards', type='int', default=os.environ.get('GTEST_TOTAL_SHARDS'), help='Total number of shards to calculate from the --index to run') options, args = parser.parse_args() env = os.environ.copy() env['GTEST_TOTAL_SHARDS'] = str(options.shards) env['GTEST_SHARD_INDEX'] = str(options.index) return subprocess.call(run_isolated.fix_python_path(args), env=env)
def main(argv): """CLI frontend to validate arguments.""" parser = OptionParserTestCases( usage='%prog <options> [gtest]', verbose=int(os.environ.get('ISOLATE_DEBUG', 0))) parser.add_option( '--run-all', action='store_true', help='Do not fail early when a large number of test cases fail') parser.add_option( '--max-failures', type='int', help='Limit the number of failures before aborting') parser.add_option( '--retries', type='int', default=2, help='Number of times each test case should be retried in case of ' 'failure.') parser.add_option( '--no-dump', action='store_true', help='do not generate a .run_test_cases file') parser.add_option( '--no-cr', action='store_true', help='Use LF instead of CR for status progress') parser.add_option( '--result', help='Override the default name of the generated .run_test_cases file') group = optparse.OptionGroup(parser, 'google-test compability flags') group.add_option( '--gtest_list_tests', action='store_true', help='List all the test cases unformatted. Keeps compatibility with the ' 'executable itself.') group.add_option( '--gtest_output', default=os.environ.get('GTEST_OUTPUT', ''), help='XML output to generate') parser.add_option_group(group) options, args = parser.parse_args(argv) if not args: parser.error( 'Please provide the executable line to run, if you need fancy things ' 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' '.') if options.run_all and options.max_failures is not None: parser.error('Use only one of --run-all or --max-failures') cmd = fix_python_path(args) if options.gtest_list_tests: # Special case, return the output of the target unmodified. return subprocess.call(cmd + ['--gtest_list_tests']) cwd = os.getcwd() test_cases = parser.process_gtest_options(cmd, cwd, options) if not test_cases: # If test_cases is None then there was a problem generating the tests to # run, so this should be considered a failure. return int(test_cases is None) if options.no_dump: result_file = None else: result_file = options.result or '%s.run_test_cases' % args[-1] return run_test_cases( cmd, cwd, test_cases, options.jobs, options.timeout, options.retries, options.run_all, options.max_failures, options.no_cr, options.gtest_output, result_file, options.verbose)