OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" | 5 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" |
6 | 6 |
7 import fnmatch | 7 import fnmatch |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
11 import shutil | 11 import shutil |
12 import sys | 12 import sys |
13 import tempfile | |
13 import time | 14 import time |
14 | 15 |
15 import android_commands | 16 import android_commands |
16 import apk_info | 17 import apk_info |
17 from base_test_runner import BaseTestRunner | 18 from base_test_runner import BaseTestRunner |
18 from base_test_sharder import BaseTestSharder, SetTestsContainer | 19 from base_test_sharder import BaseTestSharder, SetTestsContainer |
19 import cmd_helper | 20 import cmd_helper |
20 import constants | 21 import constants |
21 import errors | 22 import errors |
22 from forwarder import Forwarder | 23 from forwarder import Forwarder |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 self.tests_iter = (BaseTestSharder.tests_container) | 156 self.tests_iter = (BaseTestSharder.tests_container) |
156 assert self.tests_iter | 157 assert self.tests_iter |
157 return self.tests_iter | 158 return self.tests_iter |
158 | 159 |
159 def CopyTestFilesOnce(self): | 160 def CopyTestFilesOnce(self): |
160 """Pushes the test data files to the device. Installs the apk if opted.""" | 161 """Pushes the test data files to the device. Installs the apk if opted.""" |
161 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 162 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
162 logging.warning('Already copied test files to device %s, skipping.', | 163 logging.warning('Already copied test files to device %s, skipping.', |
163 self.device) | 164 self.device) |
164 return | 165 return |
165 host_test_files_path = (constants.CHROME_DIR + | 166 host_test_files_paths = [ |
166 '/chrome/test/data/android/device_files') | 167 constants.CHROME_DIR + '/android_webview/test/data/device_files', |
167 if os.path.exists(host_test_files_path): | 168 constants.CHROME_DIR + '/content/test/data/android/device_files', |
168 self.adb.PushIfNeeded(host_test_files_path, | 169 constants.CHROME_DIR + '/chrome/test/data/android/device_files' |
169 TestRunner._DEVICE_DATA_DIR) | 170 ] |
171 try: | |
172 temp_dir = tempfile.mkdtemp() | |
173 for src_dir in host_test_files_paths: | |
174 # shutil.copytree requires the destination directory not to exist, | |
175 # thus it can't be used for directory merges. | |
176 if os.path.exists(src_dir): | |
177 cmd_helper.RunCmd(['cp', '-r', src_dir, temp_dir]) | |
bulach
2012/09/11 10:35:06
hmm.. how many tests do we have versus how many fi
mnaganov (inactive)
2012/09/11 16:45:03
OK, changed to avoid merging -- looks simpler. Thi
| |
178 temp_files_dir = os.path.join(temp_dir, 'device_files') | |
179 if os.path.exists(temp_files_dir): | |
180 self.adb.PushIfNeeded(temp_files_dir, | |
181 TestRunner._DEVICE_DATA_DIR) | |
182 finally: | |
183 shutil.rmtree(temp_dir) | |
170 if self.install_apk: | 184 if self.install_apk: |
171 for apk in self.apks: | 185 for apk in self.apks: |
172 self.adb.ManagedInstall(apk.GetApkPath(), | 186 self.adb.ManagedInstall(apk.GetApkPath(), |
173 package_name=apk.GetPackageName()) | 187 package_name=apk.GetPackageName()) |
174 self.tool.CopyFiles() | 188 self.tool.CopyFiles() |
175 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True | 189 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True |
176 | 190 |
177 def SaveCoverageData(self, test): | 191 def SaveCoverageData(self, test): |
178 """Saves the Emma coverage data before it's overwritten by the next test. | 192 """Saves the Emma coverage data before it's overwritten by the next test. |
179 | 193 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 | 591 |
578 logging.info('Will run: %s', str(tests)) | 592 logging.info('Will run: %s', str(tests)) |
579 | 593 |
580 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 594 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
581 logging.warning('Coverage / debugger can not be sharded, ' | 595 logging.warning('Coverage / debugger can not be sharded, ' |
582 'using first available device') | 596 'using first available device') |
583 attached_devices = attached_devices[:1] | 597 attached_devices = attached_devices[:1] |
584 sharder = TestSharder(attached_devices, options, tests, apks) | 598 sharder = TestSharder(attached_devices, options, tests, apks) |
585 test_results = sharder.RunShardedTests() | 599 test_results = sharder.RunShardedTests() |
586 return test_results | 600 return test_results |
OLD | NEW |