| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import socket | 10 import socket |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 for test_suite in test_suite_iter: | 667 for test_suite in test_suite_iter: |
| 668 for test_case in test_suite: | 668 for test_case in test_suite: |
| 669 for test in test_case: | 669 for test in test_case: |
| 670 # Drop the file name in the form <filename>.<classname>.<methodname> | 670 # Drop the file name in the form <filename>.<classname>.<methodname> |
| 671 test_id = test.id()[test.id().find('.') + 1:] | 671 test_id = test.id()[test.id().find('.') + 1:] |
| 672 if re.match(test_filter_re, test_id): | 672 if re.match(test_filter_re, test_id): |
| 673 tests.addTest(test) | 673 tests.addTest(test) |
| 674 testRunner = unittest.runner.TextTestRunner(verbosity=2, | 674 testRunner = unittest.runner.TextTestRunner(verbosity=2, |
| 675 failfast=flags.failfast, buffer=(not flags.disable_buffer)) | 675 failfast=flags.failfast, buffer=(not flags.disable_buffer)) |
| 676 testRunner.run(tests) | 676 testRunner.run(tests) |
| 677 | |
| 678 # Platform-specific decorators. | |
| 679 # These decorators can be used to only run a test function for certain platforms | |
| 680 # by annotating the function with them. | |
| 681 | |
| 682 def AndroidOnly(func): | |
| 683 def wrapper(*args, **kwargs): | |
| 684 if ParseFlags().android: | |
| 685 func(*args, **kwargs) | |
| 686 else: | |
| 687 args[0].skipTest('This test runs on Android only.') | |
| 688 return wrapper | |
| 689 | |
| 690 def NotAndroid(func): | |
| 691 def wrapper(*args, **kwargs): | |
| 692 if not ParseFlags().android: | |
| 693 func(*args, **kwargs) | |
| 694 else: | |
| 695 args[0].skipTest('This test does not run on Android.') | |
| 696 return wrapper | |
| 697 | |
| 698 def WindowsOnly(func): | |
| 699 def wrapper(*args, **kwargs): | |
| 700 if sys.platform == 'win32': | |
| 701 func(*args, **kwargs) | |
| 702 else: | |
| 703 args[0].skipTest('This test runs on Windows only.') | |
| 704 return wrapper | |
| 705 | |
| 706 def NotWindows(func): | |
| 707 def wrapper(*args, **kwargs): | |
| 708 if sys.platform != 'win32': | |
| 709 func(*args, **kwargs) | |
| 710 else: | |
| 711 args[0].skipTest('This test does not run on Windows.') | |
| 712 return wrapper | |
| 713 | |
| 714 def LinuxOnly(func): | |
| 715 def wrapper(*args, **kwargs): | |
| 716 if sys.platform.startswith('linux'): | |
| 717 func(*args, **kwargs) | |
| 718 else: | |
| 719 args[0].skipTest('This test runs on Linux only.') | |
| 720 return wrapper | |
| 721 | |
| 722 def NotLinux(func): | |
| 723 def wrapper(*args, **kwargs): | |
| 724 if sys.platform.startswith('linux'): | |
| 725 func(*args, **kwargs) | |
| 726 else: | |
| 727 args[0].skipTest('This test does not run on Linux.') | |
| 728 return wrapper | |
| 729 | |
| 730 def MacOnly(func): | |
| 731 def wrapper(*args, **kwargs): | |
| 732 if sys.platform == 'darwin': | |
| 733 func(*args, **kwargs) | |
| 734 else: | |
| 735 args[0].skipTest('This test runs on Mac OS only.') | |
| 736 return wrapper | |
| 737 | |
| 738 def NotMac(func): | |
| 739 def wrapper(*args, **kwargs): | |
| 740 if sys.platform == 'darwin': | |
| 741 func(*args, **kwargs) | |
| 742 else: | |
| 743 args[0].skipTest('This test does not run on Mac OS.') | |
| 744 return wrapper | |
| OLD | NEW |