Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: build/android/pylib/gtest/gtest_test_instance.py

Issue 781573002: [Android] Add a gtest test instance for the test runner's platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/base/test_instance_factory.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 # Used for filtering large data deps at a finer grain than what's allowed in
19 # isolate files since pushing deps to devices is expensive.
20 # Wildcards are allowed.
21 _DEPS_EXCLUSION_LIST = [
22 'chrome/test/data/extensions/api_test',
23 'chrome/test/data/extensions/secure_shell',
24 'chrome/test/data/firefox*',
25 'chrome/test/data/gpu',
26 'chrome/test/data/image_decoding',
27 'chrome/test/data/import',
28 'chrome/test/data/page_cycler',
29 'chrome/test/data/perf',
30 'chrome/test/data/pyauto_private',
31 'chrome/test/data/safari_import',
32 'chrome/test/data/scroll',
33 'chrome/test/data/third_party',
34 'third_party/hunspell_dictionaries/*.dic',
35 # crbug.com/258690
36 'webkit/data/bmp_decoder',
37 'webkit/data/ico_decoder',
38 ]
39
40
41 class GtestTestInstance(test_instance.TestInstance):
42
43 def __init__(self, options, isolate_delegate):
44 super(GtestTestInstance, self).__init__()
45 self._apk_path = os.path.join(
46 constants.GetOutDirectory(), '%s_apk' % options.suite_name,
47 '%s-debug.apk' % options.suite_name)
48 self._data_deps = []
49 self._gtest_filter = options.test_filter
50 if options.isolate_file_path:
51 self._isolate_abs_path = os.path.abspath(options.isolate_file_path)
52 self._isolate_delegate = isolate_delegate
53 self._isolated_abs_path = os.path.join(
54 constants.GetOutDirectory(), '%s.isolated' % options.suite_name)
55 else:
56 logging.warning('No isolate file provided. No data deps will be pushed.');
57 self._isolate_delegate = None
58 self._suite = options.suite_name
59
60 #override
61 def TestType(self):
62 return 'gtest'
63
64 #override
65 def SetUp(self):
66 """Map data dependencies via isolate."""
67 if self._isolate_delegate:
68 self._isolate_delegate.Remap(
69 self._isolate_abs_path, self._isolated_abs_path)
70 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST)
71 self._isolate_delegate.MoveOutputDeps()
72 self._data_deps.extend([(constants.ISOLATE_DEPS_DIR, None)])
73
74 def GetDataDependencies(self):
75 """Returns the test suite's data dependencies.
76
77 Returns:
78 A list of (host_path, device_path) tuples to push. If device_path is
79 None, the client is responsible for determining where to push the file.
80 """
81 return self._data_deps
82
83 def FilterTests(self, test_list, disabled_prefixes=None):
84 """Filters |test_list| based on prefixes and, if present, a filter string.
85
86 Args:
87 test_list: The list of tests to filter.
88 disabled_prefixes: A list of test prefixes to filter. Defaults to
89 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_
90 Returns:
91 A filtered list of tests to run.
92 """
93 gtest_filter_strings = [
94 self._GenerateDisabledFilterString(disabled_prefixes)]
95 if self._gtest_filter:
96 gtest_filter_strings.append(self._gtest_filter)
97
98 filtered_test_list = test_list
99 for gtest_filter_string in gtest_filter_strings:
100 logging.info('gtest filter string: %s' % gtest_filter_string)
101 filtered_test_list = unittest_util.FilterTestNames(
102 filtered_test_list, gtest_filter_string)
103 logging.info('final list of tests: %s' % (str(filtered_test_list)))
104 return filtered_test_list
105
106 def _GenerateDisabledFilterString(self, disabled_prefixes):
107 disabled_filter_items = []
108
109 if disabled_prefixes is None:
110 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_']
111 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes]
112
113 disabled_tests_file_path = os.path.join(
114 constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest',
115 'filter', '%s_disabled' % self._suite)
116 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path):
117 with open(disabled_tests_file_path) as disabled_tests_file:
118 disabled_filter_items += [
119 '%s' % l for l in (line.strip() for line in disabled_tests_file)
120 if l and not l.startswith('#')]
121
122 return '*-%s' % ':'.join(disabled_filter_items)
123
124 #override
125 def TearDown(self):
126 """Clear the mappings created by SetUp."""
127 if self._isolate_delegate:
128 self._isolate_delegate.Clear()
129
130 @property
131 def apk(self):
132 return self._apk_path
133
134 @property
135 def suite(self):
136 return self._suite
137
OLDNEW
« no previous file with comments | « build/android/pylib/base/test_instance_factory.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698