Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: tools/isolate/run_test_cases.py

Issue 10829014: Add --gtest_filter support to run_test_cases.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/isolate/run_test_cases_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs each test cases as a single shard, single process execution. 6 """Runs each test cases as a single shard, single process execution.
7 7
8 Similar to sharding_supervisor.py but finer grained. Runs multiple instances in 8 Similar to sharding_supervisor.py but finer grained. Runs multiple instances in
9 parallel. 9 parallel.
10 """ 10 """
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 print 'Flaky: %4d %5.2f%%' % (len(flaky), len(flaky) * 100. / total) 550 print 'Flaky: %4d %5.2f%%' % (len(flaky), len(flaky) * 100. / total)
551 print 'Fail: %4d %5.2f%%' % (len(fail), len(fail) * 100. / total) 551 print 'Fail: %4d %5.2f%%' % (len(fail), len(fail) * 100. / total)
552 print '%.1fs Done running %d tests with %d executions. %.1f test/s' % ( 552 print '%.1fs Done running %d tests with %d executions. %.1f test/s' % (
553 duration, 553 duration,
554 len(results), 554 len(results),
555 nb_runs, 555 nb_runs,
556 nb_runs / duration) 556 nb_runs / duration)
557 return int(bool(fail)) 557 return int(bool(fail))
558 558
559 559
560 def main(): 560 def main(argv):
561 """CLI frontend to validate arguments.""" 561 """CLI frontend to validate arguments."""
562 def as_digit(variable, default): 562 def as_digit(variable, default):
563 if variable.isdigit(): 563 if variable.isdigit():
564 return int(variable) 564 return int(variable)
565 return default 565 return default
566 566
567 parser = optparse.OptionParser(usage='%prog <options> [gtest]') 567 parser = optparse.OptionParser(usage='%prog <options> [gtest]')
568 parser.add_option( 568 parser.add_option(
569 '-j', '--jobs', 569 '-j', '--jobs',
570 type='int', 570 type='int',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 default=as_digit(os.environ.get('GTEST_SHARD_INDEX', ''), None), 604 default=as_digit(os.environ.get('GTEST_SHARD_INDEX', ''), None),
605 help='Shard index to run') 605 help='Shard index to run')
606 group.add_option( 606 group.add_option(
607 '-s', '--shards', 607 '-s', '--shards',
608 type='int', 608 type='int',
609 default=as_digit(os.environ.get('GTEST_TOTAL_SHARDS', ''), None), 609 default=as_digit(os.environ.get('GTEST_TOTAL_SHARDS', ''), None),
610 help='Total number of shards to calculate from the --index to run') 610 help='Total number of shards to calculate from the --index to run')
611 group.add_option( 611 group.add_option(
612 '-T', '--test-case-file', 612 '-T', '--test-case-file',
613 help='File containing the exact list of test cases to run') 613 help='File containing the exact list of test cases to run')
614 group.add_option(
615 '--gtest_filter',
616 help='Runs a single test, provideded to keep compatibility with '
617 'other tools')
614 parser.add_option_group(group) 618 parser.add_option_group(group)
615 options, args = parser.parse_args() 619 options, args = parser.parse_args(argv)
616 620
617 levels = [logging.ERROR, logging.INFO, logging.DEBUG] 621 levels = [logging.ERROR, logging.INFO, logging.DEBUG]
618 logging.basicConfig( 622 logging.basicConfig(
619 level=levels[min(len(levels)-1, options.verbose)], 623 level=levels[min(len(levels)-1, options.verbose)],
620 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') 624 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
621 625
622 if len(args) != 1: 626 if len(args) != 1:
623 parser.error( 627 parser.error(
624 'Please provide the executable line to run, if you need fancy things ' 628 'Please provide the executable line to run, if you need fancy things '
625 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster' 629 'like xvfb, start this script from *inside* xvfb, it\'ll be much faster'
626 '.') 630 '.')
627 631
628 executable = args[0] 632 executable = args[0]
629 if not os.path.isabs(executable): 633 if not os.path.isabs(executable):
630 executable = os.path.abspath(executable) 634 executable = os.path.abspath(executable)
631 if sys.platform in ('cygwin', 'win32'): 635 if sys.platform in ('cygwin', 'win32'):
632 if not os.path.splitext(executable)[1]: 636 if not os.path.splitext(executable)[1]:
633 executable += '.exe' 637 executable += '.exe'
634 if not os.path.isfile(executable): 638 if not os.path.isfile(executable):
635 parser.error('"%s" doesn\'t exist.' % executable) 639 parser.error('"%s" doesn\'t exist.' % executable)
636 640
641 if options.gtest_filter:
642 # Override any other option.
643 # Based on UnitTestOptions::FilterMatchesTest() in
644 # http://code.google.com/p/googletest/source/browse/#svn%2Ftrunk%2Fsrc
645 if '-' in options.gtest_filter:
646 options.whitelist, options.blacklist = options.gtest_filter.split('-', 1)
647 else:
648 options.whitelist = options.gtest_filter
649 options.blacklist = ''
650 options.whitelist = [i for i in options.whitelist.split(':') if i]
651 options.blacklist = [i for i in options.blacklist.split(':') if i]
652
637 # Grab the test cases. 653 # Grab the test cases.
638 if options.test_case_file: 654 if options.test_case_file:
639 with open(options.test_case_file, 'r') as f: 655 with open(options.test_case_file, 'r') as f:
640 test_cases = filter(None, f.read().splitlines()) 656 test_cases = filter(None, f.read().splitlines())
641 else: 657 else:
642 test_cases = get_test_cases( 658 test_cases = get_test_cases(
643 executable, 659 executable,
644 options.whitelist, 660 options.whitelist,
645 options.blacklist, 661 options.blacklist,
646 options.index, 662 options.index,
647 options.shards) 663 options.shards)
648 664
649 if not test_cases: 665 if not test_cases:
650 return 666 return 0
651 667
652 return run_test_cases( 668 return run_test_cases(
653 executable, 669 executable,
654 test_cases, 670 test_cases,
655 options.jobs, 671 options.jobs,
656 options.timeout, 672 options.timeout,
657 options.no_dump) 673 options.no_dump)
658 674
659 675
660 if __name__ == '__main__': 676 if __name__ == '__main__':
661 sys.exit(main()) 677 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tools/isolate/run_test_cases_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698