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 """This script tests the installer with test cases specified in the config file. | 5 """This script tests the installer with test cases specified in the config file. |
6 | 6 |
7 For each test case, it checks that the machine states after the execution of | 7 For each test case, it checks that the machine states after the execution of |
8 each command match the expected machine states. For more details, take a look at | 8 each command match the expected machine states. For more details, take a look at |
9 the design documentation at http://goo.gl/Q0rGM6 | 9 the design documentation at http://goo.gl/Q0rGM6 |
10 """ | 10 """ |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 """ | 235 """ |
236 suite = unittest.TestSuite() | 236 suite = unittest.TestSuite() |
237 variable_expander = VariableExpander(mini_installer_path) | 237 variable_expander = VariableExpander(mini_installer_path) |
238 RunCleanCommand(force_clean, variable_expander) | 238 RunCleanCommand(force_clean, variable_expander) |
239 for test in config.tests: | 239 for test in config.tests: |
240 suite.addTest(InstallerTest(test, config, variable_expander)) | 240 suite.addTest(InstallerTest(test, config, variable_expander)) |
241 result = unittest.TextTestRunner(verbosity=2).run(suite) | 241 result = unittest.TextTestRunner(verbosity=2).run(suite) |
242 return result.wasSuccessful() | 242 return result.wasSuccessful() |
243 | 243 |
244 | 244 |
245 def IsComponentBuild(mini_installer_path): | |
246 """ Invokes the mini_installer asking whether it is a component build. | |
247 | |
248 Args: | |
249 mini_installer_path: The path to mini_installer.exe. | |
250 | |
251 Returns: | |
252 True if the mini_installer is a component build, False otherwise. | |
253 """ | |
254 query_command = mini_installer_path + ' --query-component-build' | |
255 script_dir = os.path.dirname(os.path.abspath(__file__)) | |
256 exit_status = subprocess.call(query_command, shell=True, cwd=script_dir) | |
257 return exit_status != 0 | |
258 | |
259 | |
245 def main(): | 260 def main(): |
246 usage = 'usage: %prog [options] config_filename' | 261 usage = 'usage: %prog [options] config_filename' |
247 parser = optparse.OptionParser(usage, description='Test the installer.') | 262 parser = optparse.OptionParser(usage, description='Test the installer.') |
248 parser.add_option('--build-dir', default='out', | 263 parser.add_option('--build-dir', default='out', |
249 help='Path to main build directory (the parent of the ' | 264 help='Path to main build directory (the parent of the ' |
250 'Release or Debug directory)') | 265 'Release or Debug directory)') |
251 parser.add_option('--target', default='Release', | 266 parser.add_option('--target', default='Release', |
252 help='Build target (Release or Debug)') | 267 help='Build target (Release or Debug)') |
253 parser.add_option('--force-clean', action='store_true', dest='force_clean', | 268 parser.add_option('--force-clean', action='store_true', dest='force_clean', |
254 default=False, help='Force cleaning existing installations') | 269 default=False, help='Force cleaning existing installations') |
255 options, args = parser.parse_args() | 270 options, args = parser.parse_args() |
256 if len(args) != 1: | 271 if len(args) != 1: |
257 parser.error('Incorrect number of arguments.') | 272 parser.error('Incorrect number of arguments.') |
258 config_filename = args[0] | 273 config_filename = args[0] |
259 | 274 |
260 mini_installer_path = os.path.join(options.build_dir, options.target, | 275 mini_installer_path = os.path.join(options.build_dir, options.target, |
261 'mini_installer.exe') | 276 'mini_installer.exe') |
262 assert os.path.exists(mini_installer_path), ('Could not find file %s' % | 277 assert os.path.exists(mini_installer_path), ('Could not find file %s' % |
263 mini_installer_path) | 278 mini_installer_path) |
279 | |
280 # Set the env var used by mini_installer.exe to decide to not show UI. | |
281 os.environ['MINI_INSTALLER_TEST'] = '1' | |
282 if IsComponentBuild(mini_installer_path): | |
283 print ('Component build is currently unsupported by the mini_installer: ' | |
284 'http://crbug.com/377839') | |
285 return 0 | |
gab
2014/06/06 16:08:11
Since we return here why do we also need logic via
robertshield
2014/06/06 17:19:21
IsComponentBuild calls mini_installer.
gab
2014/06/06 17:25:03
I see, but couldn't the early return for the query
robertshield
2014/06/06 17:49:06
Sure, that would make mini_installer.cc a bit mess
gab
2014/06/10 18:43:43
"temporary" ;-).
Are the mini_installer_tests bac
| |
286 | |
264 config = ParseConfigFile(config_filename) | 287 config = ParseConfigFile(config_filename) |
265 if not RunTests(mini_installer_path, config, options.force_clean): | 288 if not RunTests(mini_installer_path, config, options.force_clean): |
266 return 1 | 289 return 1 |
267 return 0 | 290 return 0 |
268 | 291 |
269 | 292 |
270 if __name__ == '__main__': | 293 if __name__ == '__main__': |
271 sys.exit(main()) | 294 sys.exit(main()) |
OLD | NEW |