1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright 2002-2005 Dave Abrahams. |
---|
4 | # Copyright 2002-2006 Vladimir Prus. |
---|
5 | # Distributed under the Boost Software License, Version 1.0. |
---|
6 | # (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | # http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | |
---|
9 | import os, sys, string |
---|
10 | from BoostBuild import get_toolset |
---|
11 | |
---|
12 | # clear environment for testing |
---|
13 | # |
---|
14 | for s in ( |
---|
15 | 'BOOST_ROOT','BOOST_BUILD_PATH','JAM_TOOLSET','BCCROOT', |
---|
16 | 'MSVCDir','MSVC','MSVCNT','MINGW','watcom' |
---|
17 | ): |
---|
18 | |
---|
19 | try: |
---|
20 | del os.environ[s] |
---|
21 | except: |
---|
22 | pass |
---|
23 | |
---|
24 | def run_tests(critical_tests, other_tests): |
---|
25 | """Runs first critical tests and then other_tests. |
---|
26 | |
---|
27 | Stops on first error, and write the name of failed test to |
---|
28 | test_results.txt. Critical tests are run in the specified order, |
---|
29 | other tests are run starting with the one that failed the last time. |
---|
30 | """ |
---|
31 | last_failed = last_failed_test() |
---|
32 | other_tests = reorder_tests(other_tests, last_failed) |
---|
33 | all_tests = critical_tests + other_tests |
---|
34 | |
---|
35 | invocation_dir = os.getcwd() |
---|
36 | |
---|
37 | failures_count = 0 |
---|
38 | for i in all_tests: |
---|
39 | print ("%-25s : " %(i)), |
---|
40 | try: |
---|
41 | __import__(i) |
---|
42 | except SystemExit: |
---|
43 | print "FAILED" |
---|
44 | if failures_count == 0: |
---|
45 | f = open(os.path.join(invocation_dir, 'test_results.txt'), 'w') |
---|
46 | f.write(i) |
---|
47 | f.close() |
---|
48 | failures_count = failures_count + 1 |
---|
49 | # Restore the current directory, which might be changed by the |
---|
50 | # test |
---|
51 | os.chdir(invocation_dir) |
---|
52 | continue |
---|
53 | print "PASSED" |
---|
54 | sys.stdout.flush() # makes testing under emacs more entertaining. |
---|
55 | |
---|
56 | # Erase the file on success |
---|
57 | if failures_count == 0: |
---|
58 | open('test_results.txt', 'w') |
---|
59 | |
---|
60 | |
---|
61 | def last_failed_test(): |
---|
62 | "Returns the name of last failed test or None" |
---|
63 | try: |
---|
64 | f = open("test_results.txt") |
---|
65 | s = string.strip(f.read()) |
---|
66 | return s |
---|
67 | except: |
---|
68 | return None |
---|
69 | |
---|
70 | def reorder_tests(tests, first_test): |
---|
71 | try: |
---|
72 | n = tests.index(first_test) |
---|
73 | return [first_test] + tests[:n] + tests[n+1:] |
---|
74 | except ValueError: |
---|
75 | return tests |
---|
76 | |
---|
77 | |
---|
78 | critical_tests = ["unit_tests", "module_actions", "startup_v1", "startup_v2"] |
---|
79 | |
---|
80 | critical_tests += ["core_d12", "core_typecheck", "core_delete_module", |
---|
81 | "core_varnames", "core_import_module"] |
---|
82 | |
---|
83 | tests = [ "rebuilds", |
---|
84 | "timedata", |
---|
85 | "project_test3", |
---|
86 | "project_test4", |
---|
87 | "generators_test", |
---|
88 | "dependency_test", |
---|
89 | "path_features", |
---|
90 | "relative_sources", |
---|
91 | "no_type", |
---|
92 | "chain", |
---|
93 | "default_build", |
---|
94 | "use_requirements", |
---|
95 | "conditionals", |
---|
96 | "stage", |
---|
97 | "prebuilt", |
---|
98 | "project_dependencies", |
---|
99 | "build_dir", |
---|
100 | "searched_lib", |
---|
101 | "make_rule", |
---|
102 | "alias", |
---|
103 | "alternatives", |
---|
104 | "default_features", |
---|
105 | "print", |
---|
106 | "ndebug", |
---|
107 | "explicit", |
---|
108 | "absolute_sources", |
---|
109 | "dependency_property", |
---|
110 | "custom_generator", |
---|
111 | "bad_dirname", |
---|
112 | "c_file", |
---|
113 | "inline", |
---|
114 | "conditionals2", |
---|
115 | "property_expansion", |
---|
116 | "loop", |
---|
117 | "conditionals3", |
---|
118 | "tag", |
---|
119 | "suffix", |
---|
120 | "inherit_toolset", |
---|
121 | "skipping", |
---|
122 | "project_glob", |
---|
123 | "project_root_constants", |
---|
124 | "double_loading", |
---|
125 | "dll_path", |
---|
126 | "regression", |
---|
127 | "composite", |
---|
128 | "library_chain", |
---|
129 | "unit_test", |
---|
130 | "standalone", |
---|
131 | "expansion", |
---|
132 | "wrapper", |
---|
133 | "duplicate", |
---|
134 | "library_property", |
---|
135 | "load_order", |
---|
136 | "wrong_project", |
---|
137 | "using", |
---|
138 | "source_locations", |
---|
139 | "out_of_tree", |
---|
140 | "notfile", |
---|
141 | "project_root_rule", |
---|
142 | "resolution", |
---|
143 | "build_file", |
---|
144 | "indirect_conditional", |
---|
145 | "build_no", |
---|
146 | "disambiguation", |
---|
147 | "clean", |
---|
148 | "lib_source_property", |
---|
149 | "implicit_dependency", |
---|
150 | "example_libraries", |
---|
151 | "example_make", |
---|
152 | "remove_requirement", |
---|
153 | ] |
---|
154 | |
---|
155 | if os.name == 'posix': |
---|
156 | tests.append("symlink") |
---|
157 | # On windows, library order is not important, so skip this test |
---|
158 | # Besides, it fails ;-) |
---|
159 | # Further, the test relies on the fact that on Linux, one |
---|
160 | # can build a shared library with unresolved symbols. This is |
---|
161 | # not true on Windows (even with cygwin gcc). |
---|
162 | if string.find(os.uname()[0], "CYGWIN") == -1: |
---|
163 | tests.append("library_order") |
---|
164 | |
---|
165 | if string.find(get_toolset(), 'gcc') == 0 or string.find(get_toolset(), 'msvc') == 0: |
---|
166 | tests.append("gcc_runtime") |
---|
167 | tests.append("pch") |
---|
168 | |
---|
169 | if "--extras" in sys.argv: |
---|
170 | tests.append("boostbook") |
---|
171 | tests.append("example_qt4") |
---|
172 | # Requires ./whatever.py to work, so is |
---|
173 | # not guaranted to work everywhere. |
---|
174 | tests.append("example_customization") |
---|
175 | # Requires gettext tools. |
---|
176 | tests.append("example_gettext") |
---|
177 | |
---|
178 | else: |
---|
179 | print 'Note: skipping extra tests' |
---|
180 | |
---|
181 | run_tests(critical_tests, tests) |
---|