| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 return False | 451 return False |
| 452 if not CheckTestMode("slow test", options.slow_tests): | 452 if not CheckTestMode("slow test", options.slow_tests): |
| 453 return False | 453 return False |
| 454 if not CheckTestMode("pass|fail test", options.pass_fail_tests): | 454 if not CheckTestMode("pass|fail test", options.pass_fail_tests): |
| 455 return False | 455 return False |
| 456 if options.no_i18n: | 456 if options.no_i18n: |
| 457 TEST_MAP["default"].remove("intl") | 457 TEST_MAP["default"].remove("intl") |
| 458 return True | 458 return True |
| 459 | 459 |
| 460 | 460 |
| 461 def ShardTests(tests, shard_count, shard_run): | 461 def ShardTests(tests, options): |
| 462 # Read gtest shard configuration from environment (e.g. set by swarming). |
| 463 # If none is present, use values passed on the command line. |
| 464 shard_count = int(os.environ.get('GTEST_TOTAL_SHARDS', options.shard_count)) |
| 465 shard_run = os.environ.get('GTEST_SHARD_INDEX') |
| 466 if shard_run is not None: |
| 467 # The v8 shard_run starts at 1, while GTEST_SHARD_INDEX starts at 0. |
| 468 shard_run = int(shard_run) + 1 |
| 469 else: |
| 470 shard_run = options.shard_run |
| 471 |
| 472 if options.shard_count > 1: |
| 473 # Log if a value was passed on the cmd line and it differs from the |
| 474 # environment variables. |
| 475 if options.shard_count != shard_count: |
| 476 print("shard_count from cmd line differs from environment variable " |
| 477 "GTEST_TOTAL_SHARDS") |
| 478 if options.shard_run > 1 and options.shard_run != shard_run: |
| 479 print("shard_run from cmd line differs from environment variable " |
| 480 "GTEST_SHARD_INDEX") |
| 481 |
| 462 if shard_count < 2: | 482 if shard_count < 2: |
| 463 return tests | 483 return tests |
| 464 if shard_run < 1 or shard_run > shard_count: | 484 if shard_run < 1 or shard_run > shard_count: |
| 465 print "shard-run not a valid number, should be in [1:shard-count]" | 485 print "shard-run not a valid number, should be in [1:shard-count]" |
| 466 print "defaulting back to running all tests" | 486 print "defaulting back to running all tests" |
| 467 return tests | 487 return tests |
| 468 count = 0 | 488 count = 0 |
| 469 shard = [] | 489 shard = [] |
| 470 for test in tests: | 490 for test in tests: |
| 471 if count % shard_count == shard_run - 1: | 491 if count % shard_count == shard_run - 1: |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 else: | 663 else: |
| 644 yield ["--random-seed=%d" % RandomSeed()] | 664 yield ["--random-seed=%d" % RandomSeed()] |
| 645 s.tests = [ | 665 s.tests = [ |
| 646 t.CopyAddingFlags(t.variant, flags) | 666 t.CopyAddingFlags(t.variant, flags) |
| 647 for t in variant_tests | 667 for t in variant_tests |
| 648 for flags in iter_seed_flags() | 668 for flags in iter_seed_flags() |
| 649 ] | 669 ] |
| 650 else: | 670 else: |
| 651 s.tests = variant_tests | 671 s.tests = variant_tests |
| 652 | 672 |
| 653 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) | 673 s.tests = ShardTests(s.tests, options) |
| 654 num_tests += len(s.tests) | 674 num_tests += len(s.tests) |
| 655 | 675 |
| 656 if options.cat: | 676 if options.cat: |
| 657 return 0 # We're done here. | 677 return 0 # We're done here. |
| 658 | 678 |
| 659 if options.report: | 679 if options.report: |
| 660 verbose.PrintReport(all_tests) | 680 verbose.PrintReport(all_tests) |
| 661 | 681 |
| 662 # Run the tests, either locally or distributed on the network. | 682 # Run the tests, either locally or distributed on the network. |
| 663 start_time = time.time() | 683 start_time = time.time() |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 verbose.PrintTestDurations(suites, overall_duration) | 724 verbose.PrintTestDurations(suites, overall_duration) |
| 705 | 725 |
| 706 if num_tests == 0: | 726 if num_tests == 0: |
| 707 print("Warning: no tests were run!") | 727 print("Warning: no tests were run!") |
| 708 | 728 |
| 709 return exit_code | 729 return exit_code |
| 710 | 730 |
| 711 | 731 |
| 712 if __name__ == "__main__": | 732 if __name__ == "__main__": |
| 713 sys.exit(Main()) | 733 sys.exit(Main()) |
| OLD | NEW |