OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import HTMLParser | 5 import HTMLParser |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 import tempfile | 9 import tempfile |
10 import xml.etree.ElementTree | 10 import xml.etree.ElementTree |
11 | 11 |
12 from devil.android import apk_helper | 12 from devil.android import apk_helper |
13 from pylib import constants | 13 from pylib import constants |
14 from pylib.constants import host_paths | 14 from pylib.constants import host_paths |
15 from pylib.base import base_test_result | 15 from pylib.base import base_test_result |
16 from pylib.base import test_instance | 16 from pylib.base import test_instance |
| 17 from pylib.utils import isolator |
17 | 18 |
18 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): | 19 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
19 import unittest_util # pylint: disable=import-error | 20 import unittest_util # pylint: disable=import-error |
20 | 21 |
21 | 22 |
22 BROWSER_TEST_SUITES = [ | 23 BROWSER_TEST_SUITES = [ |
23 'components_browsertests', | 24 'components_browsertests', |
24 'content_browsertests', | 25 'content_browsertests', |
25 ] | 26 ] |
26 | 27 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') | 223 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') |
223 if negative_patterns: | 224 if negative_patterns: |
224 negative_patterns = '-' + negative_patterns | 225 negative_patterns = '-' + negative_patterns |
225 | 226 |
226 # Join the filter lines into one, big --gtest_filter argument. | 227 # Join the filter lines into one, big --gtest_filter argument. |
227 return positive_patterns + negative_patterns | 228 return positive_patterns + negative_patterns |
228 | 229 |
229 | 230 |
230 class GtestTestInstance(test_instance.TestInstance): | 231 class GtestTestInstance(test_instance.TestInstance): |
231 | 232 |
232 def __init__(self, args, data_deps_delegate, error_func): | 233 def __init__(self, args, isolate_delegate, error_func): |
233 super(GtestTestInstance, self).__init__() | 234 super(GtestTestInstance, self).__init__() |
234 # TODO(jbudorick): Support multiple test suites. | 235 # TODO(jbudorick): Support multiple test suites. |
235 if len(args.suite_name) > 1: | 236 if len(args.suite_name) > 1: |
236 raise ValueError('Platform mode currently supports only 1 gtest suite') | 237 raise ValueError('Platform mode currently supports only 1 gtest suite') |
237 self._exe_dist_dir = None | 238 self._exe_dist_dir = None |
238 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 239 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
239 self._shard_timeout = args.shard_timeout | 240 self._shard_timeout = args.shard_timeout |
240 self._store_tombstones = args.store_tombstones | 241 self._store_tombstones = args.store_tombstones |
241 self._suite = args.suite_name[0] | 242 self._suite = args.suite_name[0] |
242 | 243 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 self._data_deps = [] | 281 self._data_deps = [] |
281 if args.test_filter: | 282 if args.test_filter: |
282 self._gtest_filter = args.test_filter | 283 self._gtest_filter = args.test_filter |
283 elif args.test_filter_file: | 284 elif args.test_filter_file: |
284 with open(args.test_filter_file, 'r') as f: | 285 with open(args.test_filter_file, 'r') as f: |
285 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) | 286 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) |
286 else: | 287 else: |
287 self._gtest_filter = None | 288 self._gtest_filter = None |
288 | 289 |
289 self._data_deps_delegate = data_deps_delegate | 290 if (args.isolate_file_path and |
290 self._runtime_deps_path = args.runtime_deps_path | 291 not isolator.IsIsolateEmpty(args.isolate_file_path)): |
291 if not self._runtime_deps_path: | 292 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) |
292 logging.warning('No data dependencies will be pushed.') | 293 self._isolate_delegate = isolate_delegate |
| 294 self._isolated_abs_path = os.path.join( |
| 295 constants.GetOutDirectory(), '%s.isolated' % self._suite) |
| 296 else: |
| 297 logging.warning('%s isolate file provided. No data deps will be pushed.', |
| 298 'Empty' if args.isolate_file_path else 'No') |
| 299 self._isolate_delegate = None |
293 | 300 |
294 if args.app_data_files: | 301 if args.app_data_files: |
295 self._app_data_files = args.app_data_files | 302 self._app_data_files = args.app_data_files |
296 if args.app_data_file_dir: | 303 if args.app_data_file_dir: |
297 self._app_data_file_dir = args.app_data_file_dir | 304 self._app_data_file_dir = args.app_data_file_dir |
298 else: | 305 else: |
299 self._app_data_file_dir = tempfile.mkdtemp() | 306 self._app_data_file_dir = tempfile.mkdtemp() |
300 logging.critical('Saving app files to %s', self._app_data_file_dir) | 307 logging.critical('Saving app files to %s', self._app_data_file_dir) |
301 else: | 308 else: |
302 self._app_data_files = None | 309 self._app_data_files = None |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 def extract_test_list_from_filter(self): | 386 def extract_test_list_from_filter(self): |
380 return self._extract_test_list_from_filter | 387 return self._extract_test_list_from_filter |
381 | 388 |
382 #override | 389 #override |
383 def TestType(self): | 390 def TestType(self): |
384 return 'gtest' | 391 return 'gtest' |
385 | 392 |
386 #override | 393 #override |
387 def SetUp(self): | 394 def SetUp(self): |
388 """Map data dependencies via isolate.""" | 395 """Map data dependencies via isolate.""" |
389 self._data_deps.extend( | 396 if self._isolate_delegate: |
390 self._data_deps_delegate(self._runtime_deps_path)) | 397 self._isolate_delegate.Remap( |
| 398 self._isolate_abs_path, self._isolated_abs_path) |
| 399 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) |
| 400 self._isolate_delegate.MoveOutputDeps() |
| 401 dest_dir = None |
| 402 self._data_deps.extend([ |
| 403 (self._isolate_delegate.isolate_deps_dir, dest_dir)]) |
| 404 |
391 | 405 |
392 def GetDataDependencies(self): | 406 def GetDataDependencies(self): |
393 """Returns the test suite's data dependencies. | 407 """Returns the test suite's data dependencies. |
394 | 408 |
395 Returns: | 409 Returns: |
396 A list of (host_path, device_path) tuples to push. If device_path is | 410 A list of (host_path, device_path) tuples to push. If device_path is |
397 None, the client is responsible for determining where to push the file. | 411 None, the client is responsible for determining where to push the file. |
398 """ | 412 """ |
399 return self._data_deps | 413 return self._data_deps |
400 | 414 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 448 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
435 with open(disabled_tests_file_path) as disabled_tests_file: | 449 with open(disabled_tests_file_path) as disabled_tests_file: |
436 disabled_filter_items += [ | 450 disabled_filter_items += [ |
437 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 451 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
438 if l and not l.startswith('#')] | 452 if l and not l.startswith('#')] |
439 | 453 |
440 return '*-%s' % ':'.join(disabled_filter_items) | 454 return '*-%s' % ':'.join(disabled_filter_items) |
441 | 455 |
442 #override | 456 #override |
443 def TearDown(self): | 457 def TearDown(self): |
444 """Do nothing.""" | 458 """Clear the mappings created by SetUp.""" |
445 pass | 459 if self._isolate_delegate: |
| 460 self._isolate_delegate.Clear() |
446 | 461 |
OLD | NEW |