| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 """Builds and runs the Chrome Frame unit and integration tests, | |
| 6 the exit status of the scrip is the number of failed tests. | |
| 7 """ | |
| 8 | |
| 9 import os.path | |
| 10 import sys | |
| 11 import win32com.client | |
| 12 | |
| 13 | |
| 14 # The top-level source directory. | |
| 15 # All other paths in this file are relative to this directory. | |
| 16 _SRC_DIR = os.path.abspath(os.path.join( | |
| 17 os.path.dirname(__file__), '../..')) | |
| 18 | |
| 19 | |
| 20 def AbsolutePath(path): | |
| 21 '''Convert path to absolute. | |
| 22 | |
| 23 Args: | |
| 24 path: a path relative to _SRC_DIR. | |
| 25 | |
| 26 Returns: Path as an absolute, normalized path. | |
| 27 ''' | |
| 28 return os.path.abspath(os.path.join(_SRC_DIR, path)) | |
| 29 | |
| 30 | |
| 31 # Solution path. | |
| 32 _CHROME_SOLUTION = AbsolutePath('chrome/chrome.sln') | |
| 33 | |
| 34 # List of project files to build. | |
| 35 _PROJECTS_TO_BUILD = [ | |
| 36 # Chrome.exe, which in turn causes chrome.dll etc to get built. | |
| 37 AbsolutePath('chrome/chrome.vcproj'), | |
| 38 | |
| 39 # Chrome Frame. | |
| 40 AbsolutePath('chrome_frame/npchrome_frame.vcproj'), | |
| 41 | |
| 42 # Chrome Frame unittests. | |
| 43 AbsolutePath('chrome_frame/chrome_frame_unittests.vcproj'), | |
| 44 AbsolutePath('chrome_frame/crash_reporting/vectored_handler_tests.vcproj'), | |
| 45 | |
| 46 # Chrome Frame integration tests. | |
| 47 AbsolutePath('chrome_frame/chrome_frame_tests.vcproj'), | |
| 48 AbsolutePath('chrome_frame/chrome_frame_net_tests.vcproj'), | |
| 49 AbsolutePath('chrome_frame/chrome_frame_perftests.vcproj'), | |
| 50 ] | |
| 51 | |
| 52 # List of test executables to run. | |
| 53 _TESTS_TO_RUN = [ | |
| 54 'chrome_frame_unittests.exe', | |
| 55 'vectored_handler_tests.exe', | |
| 56 | |
| 57 'chrome_frame_tests.exe', | |
| 58 'chrome_frame_net_tests.exe', | |
| 59 # 'chrome_frame_perftests.exe', | |
| 60 ] | |
| 61 | |
| 62 def BuildProjectConfig(builder, config, project): | |
| 63 '''Builds a given project in a given configuration, exits on error. | |
| 64 | |
| 65 Args: | |
| 66 builder: a Visual Studio SolutionBuild object. | |
| 67 config: the name of the configuration to build, f.ex. "Release". | |
| 68 project: the path of a project to build, either absolute or else relative | |
| 69 to the builder's solution directory. | |
| 70 ''' | |
| 71 print 'Building project "%s" in configuration "%s" ' % (project, config) | |
| 72 project = os.path.normpath(project) | |
| 73 builder.BuildProject(config, project, True) | |
| 74 errors = builder.LastBuildInfo | |
| 75 | |
| 76 if errors != 0: | |
| 77 print '%d errors while building config %s.' % (errors, config) | |
| 78 sys.exit(errors) | |
| 79 | |
| 80 | |
| 81 def Main(): | |
| 82 '''Builds Chrome Frame Tests and all their dependencies, | |
| 83 then runs the tests.''' | |
| 84 v = {} | |
| 85 solution = win32com.client.GetObject(_CHROME_SOLUTION) | |
| 86 builder = solution.SolutionBuild | |
| 87 | |
| 88 for project in _PROJECTS_TO_BUILD: | |
| 89 BuildProjectConfig(builder, 'Debug', project) | |
| 90 | |
| 91 # Ok, everything's built, run the tests. | |
| 92 failed_tests = 0 | |
| 93 for test in _TESTS_TO_RUN: | |
| 94 test_path = os.path.abspath(os.path.join(_SRC_DIR, 'chrome/Debug', test)) | |
| 95 exit_status = os.system(test_path) | |
| 96 if exit_status != 0: | |
| 97 failed_tests += 1 | |
| 98 print "Test \"%s\" failed with status %d" % (test, exit_status) | |
| 99 | |
| 100 return failed_tests | |
| 101 | |
| 102 | |
| 103 if __name__ == "__main__": | |
| 104 sys.exit(Main()) | |
| OLD | NEW |