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

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

Issue 22933005: [android] Make build_type a singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix call to _LogToFile Created 7 years, 4 months 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Generates test runner factory and tests for GTests.""" 5 """Generates test runner factory and tests for GTests."""
6 6
7 import fnmatch 7 import fnmatch
8 import glob 8 import glob
9 import logging 9 import logging
10 import os 10 import os
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 'third_party/hunspell_dictionaries/*.dic', 62 'third_party/hunspell_dictionaries/*.dic',
63 # crbug.com/258690 63 # crbug.com/258690
64 'webkit/data/bmp_decoder', 64 'webkit/data/bmp_decoder',
65 'webkit/data/ico_decoder', 65 'webkit/data/ico_decoder',
66 ] 66 ]
67 67
68 _ISOLATE_SCRIPT = os.path.join( 68 _ISOLATE_SCRIPT = os.path.join(
69 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') 69 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py')
70 70
71 71
72 def _GenerateDepsDirUsingIsolate(suite_name, build_type): 72 def _GenerateDepsDirUsingIsolate(suite_name):
73 """Generate the dependency dir for the test suite using isolate. 73 """Generate the dependency dir for the test suite using isolate.
74 74
75 Args: 75 Args:
76 suite_name: Name of the test suite (e.g. base_unittests). 76 suite_name: Name of the test suite (e.g. base_unittests).
77 build_type: Release/Debug
78 """ 77 """
79 product_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) 78 product_dir = os.path.join(cmd_helper.OutDirectory.get(),
79 constants.GetBuildType())
80 assert os.path.isabs(product_dir) 80 assert os.path.isabs(product_dir)
81 81
82 if os.path.isdir(constants.ISOLATE_DEPS_DIR): 82 if os.path.isdir(constants.ISOLATE_DEPS_DIR):
83 shutil.rmtree(constants.ISOLATE_DEPS_DIR) 83 shutil.rmtree(constants.ISOLATE_DEPS_DIR)
84 84
85 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) 85 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name)
86 if not isolate_rel_path: 86 if not isolate_rel_path:
87 logging.info('Did not find an isolate file for the test suite.') 87 logging.info('Did not find an isolate file for the test suite.')
88 return 88 return
89 89
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 # On Android, all pak files need to be in the top-level 'paks' directory. 136 # On Android, all pak files need to be in the top-level 'paks' directory.
137 paks_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'paks') 137 paks_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'paks')
138 os.mkdir(paks_dir) 138 os.mkdir(paks_dir)
139 for root, _, filenames in os.walk(os.path.join(constants.ISOLATE_DEPS_DIR, 139 for root, _, filenames in os.walk(os.path.join(constants.ISOLATE_DEPS_DIR,
140 'out')): 140 'out')):
141 for filename in fnmatch.filter(filenames, '*.pak'): 141 for filename in fnmatch.filter(filenames, '*.pak'):
142 shutil.move(os.path.join(root, filename), paks_dir) 142 shutil.move(os.path.join(root, filename), paks_dir)
143 143
144 # Move everything in PRODUCT_DIR to top level. 144 # Move everything in PRODUCT_DIR to top level.
145 deps_product_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'out', build_type) 145 deps_product_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'out',
146 constants.GetBuildType())
146 if os.path.isdir(deps_product_dir): 147 if os.path.isdir(deps_product_dir):
147 for p in os.listdir(deps_product_dir): 148 for p in os.listdir(deps_product_dir):
148 shutil.move(os.path.join(deps_product_dir, p), constants.ISOLATE_DEPS_DIR) 149 shutil.move(os.path.join(deps_product_dir, p), constants.ISOLATE_DEPS_DIR)
149 os.rmdir(deps_product_dir) 150 os.rmdir(deps_product_dir)
150 os.rmdir(os.path.join(constants.ISOLATE_DEPS_DIR, 'out')) 151 os.rmdir(os.path.join(constants.ISOLATE_DEPS_DIR, 'out'))
151 152
152 153
153 def _GetDisabledTestsFilterFromFile(suite_name): 154 def _GetDisabledTestsFilterFromFile(suite_name):
154 """Returns a gtest filter based on the *_disabled file. 155 """Returns a gtest filter based on the *_disabled file.
155 156
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 Args: 264 Args:
264 test_options: A GTestOptions object. 265 test_options: A GTestOptions object.
265 266
266 Returns: 267 Returns:
267 A tuple of (TestRunnerFactory, tests). 268 A tuple of (TestRunnerFactory, tests).
268 """ 269 """
269 270
270 if not ports.ResetTestServerPortAllocation(): 271 if not ports.ResetTestServerPortAllocation():
271 raise Exception('Failed to reset test server port.') 272 raise Exception('Failed to reset test server port.')
272 273
273 test_package = test_package_apk.TestPackageApk(test_options.suite_name, 274 test_package = test_package_apk.TestPackageApk(test_options.suite_name)
274 test_options.build_type)
275 if not os.path.exists(test_package.suite_path): 275 if not os.path.exists(test_package.suite_path):
276 test_package = test_package_exe.TestPackageExecutable( 276 test_package = test_package_exe.TestPackageExecutable(
277 test_options.suite_name, test_options.build_type) 277 test_options.suite_name)
278 if not os.path.exists(test_package.suite_path): 278 if not os.path.exists(test_package.suite_path):
279 raise Exception( 279 raise Exception(
280 'Did not find %s target. Ensure it has been built.' 280 'Did not find %s target. Ensure it has been built.'
281 % test_options.suite_name) 281 % test_options.suite_name)
282 logging.warning('Found target %s', test_package.suite_path) 282 logging.warning('Found target %s', test_package.suite_path)
283 283
284 _GenerateDepsDirUsingIsolate(test_options.suite_name, 284 _GenerateDepsDirUsingIsolate(test_options.suite_name)
285 test_options.build_type)
286 285
287 # Constructs a new TestRunner with the current options. 286 # Constructs a new TestRunner with the current options.
288 def TestRunnerFactory(device, shard_index): 287 def TestRunnerFactory(device, shard_index):
289 return test_runner.TestRunner( 288 return test_runner.TestRunner(
290 test_options, 289 test_options,
291 device, 290 device,
292 test_package) 291 test_package)
293 292
294 attached_devices = android_commands.GetAttachedDevices() 293 attached_devices = android_commands.GetAttachedDevices()
295 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, 294 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter,
296 TestRunnerFactory, attached_devices) 295 TestRunnerFactory, attached_devices)
297 # Coalesce unit tests into a single test per device 296 # Coalesce unit tests into a single test per device
298 if test_options.suite_name != 'content_browsertests': 297 if test_options.suite_name != 'content_browsertests':
299 num_devices = len(attached_devices) 298 num_devices = len(attached_devices)
300 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] 299 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)]
301 tests = [t for t in tests if t] 300 tests = [t for t in tests if t]
302 301
303 return (TestRunnerFactory, tests) 302 return (TestRunnerFactory, tests)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698