• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3# found in the LICENSE file.
4
5
6def HostOnlyTest(func):
7  """Decorator for running unit tests only on the host device.
8
9  This will disable unit tests from running on Android devices.
10  """
11  return _SkipTestDecoratorHelper(func, ['android'])
12
13
14def ClientOnlyTest(func):
15  """Decorator for running unit tests only on client devices (Android).
16  """
17  return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac'])
18
19
20def Disabled(func):
21  """Decorator for not running a unit test on any Trybot platform.
22  """
23  return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac', 'android'])
24
25
26def LinuxMacTest(func):
27  return _SkipTestDecoratorHelper(func, ['win', 'android'])
28
29
30def _SkipTestDecoratorHelper(func, disabled_strings):
31  if not hasattr(func, '_disabled_strings'):
32    setattr(func, '_disabled_strings', set(disabled_strings))
33  return func
34
35
36def ShouldSkip(test, device):
37  """Returns whether the test should be skipped and the reason for it."""
38  if hasattr(test, '_disabled_strings'):
39    disabled_devices = getattr(test, '_disabled_strings')
40    return device in disabled_devices
41  return False
42