OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2014 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 import logging | |
6 import os | |
7 import shutil | |
8 import sys | |
9 | |
10 from pylib import constants | |
11 from pylib.base import test_instance | |
12 | |
13 sys.path.append(os.path.join( | |
14 constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')) | |
15 import unittest_util | |
16 | |
17 | |
18 _DEPS_EXCLUSION_LIST = [ | |
klundberg
2014/12/03 21:22:45
I'm assuming this is something from the existing s
jbudorick
2014/12/03 21:42:43
It is (see build/android/pylib/gtest/setup.py). Pu
| |
19 'chrome/test/data/extensions/api_test', | |
20 'chrome/test/data/extensions/secure_shell', | |
21 'chrome/test/data/firefox*', | |
22 'chrome/test/data/gpu', | |
23 'chrome/test/data/image_decoding', | |
24 'chrome/test/data/import', | |
25 'chrome/test/data/page_cycler', | |
26 'chrome/test/data/perf', | |
27 'chrome/test/data/pyauto_private', | |
28 'chrome/test/data/safari_import', | |
29 'chrome/test/data/scroll', | |
30 'chrome/test/data/third_party', | |
31 'third_party/hunspell_dictionaries/*.dic', | |
32 # crbug.com/258690 | |
33 'webkit/data/bmp_decoder', | |
34 'webkit/data/ico_decoder', | |
35 ] | |
36 | |
37 | |
38 class GtestTestInstance(test_instance.TestInstance): | |
39 | |
40 def __init__(self, options, isolate_delegate): | |
41 super(GtestTestInstance, self).__init__() | |
42 self._apk_path = os.path.join( | |
43 constants.GetOutDirectory(), '%s_apk' % options.suite_name, | |
44 '%s-debug.apk' % options.suite_name) | |
45 self._data_deps = [] | |
46 self._gtest_filter = options.test_filter | |
47 if options.isolate_file_path: | |
48 self._isolate_abs_path = os.path.abspath(options.isolate_file_path) | |
49 self._isolate_delegate = isolate_delegate | |
50 self._isolated_abs_path = os.path.join( | |
51 constants.GetOutDirectory(), '%s.isolated' % options.suite_name) | |
52 else: | |
53 logging.warning('No isolate file provided. No data deps will be pushed.'); | |
54 self._isolate_delegate = None | |
55 self._suite = options.suite_name | |
56 | |
57 #override | |
58 def TestType(self): | |
59 return 'gtest' | |
60 | |
61 #override | |
62 def SetUp(self): | |
63 """Map data dependencies via isolate.""" | |
64 if self._isolate_delegate: | |
65 self._isolate_delegate.Remap( | |
66 self._isolate_abs_path, self._isolated_abs_path) | |
67 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) | |
68 self._isolate_delegate.MoveOutputDeps() | |
69 self._data_deps.extend([(constants.ISOLATE_DEPS_DIR, None)]) | |
70 | |
71 def GetDataDependencies(self): | |
72 """Returns the test suite's data dependencies. | |
73 | |
74 Returns: | |
75 A list of (host_path, device_path) tuples to push. If device_path is | |
76 None, the client is responsible for determining where to push the file. | |
77 """ | |
78 return self._data_deps | |
79 | |
80 def FilterTests(self, test_list, disabled_prefixes=None): | |
81 """Filters |test_list| based on prefixes and, if present, a filter string. | |
82 | |
83 Args: | |
84 test_list: The list of tests to filter. | |
85 disabled_prefixes: A list of test prefixes to filter. Defaults to | |
86 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_ | |
87 Returns: | |
88 A filtered list of tests to run. | |
89 """ | |
90 gtest_filter_strings = [ | |
91 self._GenerateDisabledFilterString(disabled_prefixes)] | |
92 if self._gtest_filter: | |
93 gtest_filter_strings.append(self._gtest_filter) | |
94 | |
95 filtered_test_list = test_list | |
96 for gtest_filter_string in gtest_filter_strings: | |
97 logging.info('gtest filter string: %s' % gtest_filter_string) | |
98 filtered_test_list = unittest_util.FilterTestNames( | |
99 filtered_test_list, gtest_filter_string) | |
100 logging.info('final list of tests: %s' % (str(filtered_test_list))) | |
101 return filtered_test_list | |
102 | |
103 def _GenerateDisabledFilterString(self, disabled_prefixes): | |
104 disabled_filter_items = [] | |
105 | |
106 if disabled_prefixes is None: | |
107 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_'] | |
108 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] | |
109 | |
110 disabled_tests_file_path = os.path.join( | |
111 constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', | |
112 'filter', '%s_disabled' % self._suite) | |
113 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | |
114 with open(disabled_tests_file_path) as disabled_tests_file: | |
115 disabled_filter_items += [ | |
116 '%s' % l for l in (line.strip() for line in disabled_tests_file) | |
117 if l and not l.startswith('#')] | |
118 | |
119 return '*-%s' % ':'.join(disabled_filter_items) | |
120 | |
121 #override | |
122 def TearDown(self): | |
123 """Clear the mappings created by SetUp.""" | |
124 if self._isolate_delegate: | |
125 self._isolate_delegate.Clear() | |
126 | |
rnephew (Reviews Here)
2014/12/03 21:28:36
In the DD you mention "def GetApkUnderTest(self):"
jbudorick
2014/12/03 21:42:43
Somewhere else. (In this case, right here.) Not ev
| |
127 @property | |
128 def apk(self): | |
129 return self._apk_path | |
130 | |
131 @property | |
132 def suite(self): | |
133 return self._suite | |
134 | |
OLD | NEW |