OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from common import ParseFlags |
| 6 |
| 7 |
| 8 # Platform-specific decorators. |
| 9 # These decorators can be used to only run a test function for certain platforms |
| 10 # by annotating the function with them. |
| 11 |
| 12 def AndroidOnly(func): |
| 13 def wrapper(*args, **kwargs): |
| 14 if ParseFlags().android: |
| 15 func(*args, **kwargs) |
| 16 else: |
| 17 args[0].skipTest('This test runs on Android only.') |
| 18 return wrapper |
| 19 |
| 20 def NotAndroid(func): |
| 21 def wrapper(*args, **kwargs): |
| 22 if not ParseFlags().android: |
| 23 func(*args, **kwargs) |
| 24 else: |
| 25 args[0].skipTest('This test does not run on Android.') |
| 26 return wrapper |
| 27 |
| 28 def WindowsOnly(func): |
| 29 def wrapper(*args, **kwargs): |
| 30 if sys.platform == 'win32': |
| 31 func(*args, **kwargs) |
| 32 else: |
| 33 args[0].skipTest('This test runs on Windows only.') |
| 34 return wrapper |
| 35 |
| 36 def NotWindows(func): |
| 37 def wrapper(*args, **kwargs): |
| 38 if sys.platform != 'win32': |
| 39 func(*args, **kwargs) |
| 40 else: |
| 41 args[0].skipTest('This test does not run on Windows.') |
| 42 return wrapper |
| 43 |
| 44 def LinuxOnly(func): |
| 45 def wrapper(*args, **kwargs): |
| 46 if sys.platform.startswith('linux'): |
| 47 func(*args, **kwargs) |
| 48 else: |
| 49 args[0].skipTest('This test runs on Linux only.') |
| 50 return wrapper |
| 51 |
| 52 def NotLinux(func): |
| 53 def wrapper(*args, **kwargs): |
| 54 if sys.platform.startswith('linux'): |
| 55 func(*args, **kwargs) |
| 56 else: |
| 57 args[0].skipTest('This test does not run on Linux.') |
| 58 return wrapper |
| 59 |
| 60 def MacOnly(func): |
| 61 def wrapper(*args, **kwargs): |
| 62 if sys.platform == 'darwin': |
| 63 func(*args, **kwargs) |
| 64 else: |
| 65 args[0].skipTest('This test runs on Mac OS only.') |
| 66 return wrapper |
| 67 |
| 68 def NotMac(func): |
| 69 def wrapper(*args, **kwargs): |
| 70 if sys.platform == 'darwin': |
| 71 func(*args, **kwargs) |
| 72 else: |
| 73 args[0].skipTest('This test does not run on Mac OS.') |
| 74 return wrapper |
OLD | NEW |