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.
11 import win32com
.client
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__
), '../..'))
20 def AbsolutePath(path
):
21 '''Convert path to absolute.
24 path: a path relative to _SRC_DIR.
26 Returns: Path as an absolute, normalized path.
28 return os
.path
.abspath(os
.path
.join(_SRC_DIR
, path
))
32 _CHROME_SOLUTION
= AbsolutePath('chrome/chrome.sln')
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'),
40 AbsolutePath('chrome_frame/npchrome_frame.vcproj'),
42 # Chrome Frame unittests.
43 AbsolutePath('chrome_frame/chrome_frame_unittests.vcproj'),
44 AbsolutePath('chrome_frame/crash_reporting/vectored_handler_tests.vcproj'),
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'),
52 # List of test executables to run.
54 'chrome_frame_unittests.exe',
55 'vectored_handler_tests.exe',
57 'chrome_frame_tests.exe',
58 'chrome_frame_net_tests.exe',
59 # 'chrome_frame_perftests.exe',
62 def BuildProjectConfig(builder
, config
, project
):
63 '''Builds a given project in a given configuration, exits on error.
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.
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
77 print '%d errors while building config %s.' % (errors
, config
)
82 '''Builds Chrome Frame Tests and all their dependencies,
83 then runs the tests.'''
85 solution
= win32com
.client
.GetObject(_CHROME_SOLUTION
)
86 builder
= solution
.SolutionBuild
88 for project
in _PROJECTS_TO_BUILD
:
89 BuildProjectConfig(builder
, 'Debug', project
)
91 # Ok, everything's built, run the tests.
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
)
98 print "Test \"%s\" failed with status %d" % (test
, exit_status
)
103 if __name__
== "__main__":