OLD | NEW |
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 _ISOLATE_SCRIPT = os.path.join( | 89 _ISOLATE_SCRIPT = os.path.join( |
90 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') | 90 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') |
91 | 91 |
92 | 92 |
93 def _GenerateDepsDirUsingIsolate(suite_name): | 93 def _GenerateDepsDirUsingIsolate(suite_name): |
94 """Generate the dependency dir for the test suite using isolate. | 94 """Generate the dependency dir for the test suite using isolate. |
95 | 95 |
96 Args: | 96 Args: |
97 suite_name: Name of the test suite (e.g. base_unittests). | 97 suite_name: Name of the test suite (e.g. base_unittests). |
98 """ | 98 """ |
99 product_dir = os.path.join(cmd_helper.OutDirectory.get(), | |
100 constants.GetBuildType()) | |
101 assert os.path.isabs(product_dir) | |
102 | |
103 if os.path.isdir(constants.ISOLATE_DEPS_DIR): | 99 if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
104 shutil.rmtree(constants.ISOLATE_DEPS_DIR) | 100 shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
105 | 101 |
106 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) | 102 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) |
107 if not isolate_rel_path: | 103 if not isolate_rel_path: |
108 logging.info('Did not find an isolate file for the test suite.') | 104 logging.info('Did not find an isolate file for the test suite.') |
109 return | 105 return |
110 | 106 |
111 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | 107 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
112 isolated_abs_path = os.path.join( | 108 isolated_abs_path = os.path.join( |
113 product_dir, '%s.isolated' % suite_name) | 109 constants.GetOutDirectory(), '%s.isolated' % suite_name) |
114 assert os.path.exists(isolate_abs_path) | 110 assert os.path.exists(isolate_abs_path) |
115 isolate_cmd = [ | 111 isolate_cmd = [ |
116 'python', _ISOLATE_SCRIPT, | 112 'python', _ISOLATE_SCRIPT, |
117 'remap', | 113 'remap', |
118 '--isolate', isolate_abs_path, | 114 '--isolate', isolate_abs_path, |
119 '--isolated', isolated_abs_path, | 115 '--isolated', isolated_abs_path, |
120 '-V', 'PRODUCT_DIR=%s' % product_dir, | 116 '-V', 'PRODUCT_DIR=%s' % constants.GetOutDirectory(), |
121 '-V', 'OS=android', | 117 '-V', 'OS=android', |
122 '--outdir', constants.ISOLATE_DEPS_DIR, | 118 '--outdir', constants.ISOLATE_DEPS_DIR, |
123 ] | 119 ] |
124 assert not cmd_helper.RunCmd(isolate_cmd) | 120 assert not cmd_helper.RunCmd(isolate_cmd) |
125 | 121 |
126 # We're relying on the fact that timestamps are preserved | 122 # We're relying on the fact that timestamps are preserved |
127 # by the remap command (hardlinked). Otherwise, all the data | 123 # by the remap command (hardlinked). Otherwise, all the data |
128 # will be pushed to the device once we move to using time diff | 124 # will be pushed to the device once we move to using time diff |
129 # instead of md5sum. Perform a sanity check here. | 125 # instead of md5sum. Perform a sanity check here. |
130 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): | 126 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 310 |
315 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, | 311 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, |
316 TestRunnerFactory, devices) | 312 TestRunnerFactory, devices) |
317 # Coalesce unit tests into a single test per device | 313 # Coalesce unit tests into a single test per device |
318 if test_options.suite_name != 'content_browsertests': | 314 if test_options.suite_name != 'content_browsertests': |
319 num_devices = len(devices) | 315 num_devices = len(devices) |
320 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 316 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
321 tests = [t for t in tests if t] | 317 tests = [t for t in tests if t] |
322 | 318 |
323 return (TestRunnerFactory, tests) | 319 return (TestRunnerFactory, tests) |
OLD | NEW |