1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
def HostOnlyTest(func):
"""Decorator for running unit tests only on the host device.
This will disable unit tests from running on Android devices.
"""
return _SkipTestDecoratorHelper(func, ['android'])
def ClientOnlyTest(func):
"""Decorator for running unit tests only on client devices (Android).
"""
return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac'])
def Disabled(func):
"""Decorator for not running a unit test on any Trybot platform.
"""
return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac', 'android'])
def LinuxMacTest(func):
return _SkipTestDecoratorHelper(func, ['win', 'android'])
def _SkipTestDecoratorHelper(func, disabled_strings):
if not hasattr(func, '_disabled_strings'):
setattr(func, '_disabled_strings', set(disabled_strings))
return func
def ShouldSkip(test, device):
"""Returns whether the test should be skipped and the reason for it."""
if hasattr(test, '_disabled_strings'):
disabled_devices = getattr(test, '_disabled_strings')
return device in disabled_devices
return False
|