]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/test_all.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / test_all.py
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.txt or copy at
7 # https://www.bfgroup.xyz/b2/LICENSE.txt)
8
9 from __future__ import print_function
10
11 import BoostBuild
12
13 import os
14 import os.path
15 import sys
16
17 xml = "--xml" in sys.argv
18 toolset = BoostBuild.get_toolset()
19
20
21 # Clear environment for testing.
22 #
23 for s in ("BOOST_ROOT", "BOOST_BUILD_PATH", "JAM_TOOLSET", "BCCROOT",
24 "MSVCDir", "MSVC", "MSVCNT", "MINGW", "watcom"):
25 try:
26 del os.environ[s]
27 except:
28 pass
29
30 BoostBuild.set_defer_annotations(1)
31
32
33 def run_tests(critical_tests, other_tests):
34 """
35 Runs first the critical_tests and then the other_tests.
36
37 Writes the name of the first failed test to test_results.txt. Critical
38 tests are run in the specified order, other tests are run starting with the
39 one that failed first on the last test run.
40
41 """
42 last_failed = last_failed_test()
43 other_tests = reorder_tests(other_tests, last_failed)
44 all_tests = critical_tests + other_tests
45
46 invocation_dir = os.getcwd()
47 max_test_name_len = 10
48 for x in all_tests:
49 if len(x) > max_test_name_len:
50 max_test_name_len = len(x)
51
52 pass_count = 0
53 failures_count = 0
54
55 for test in all_tests:
56 if not xml:
57 s = "%%-%ds :" % max_test_name_len % test
58 print(s, end='')
59
60 passed = 0
61 try:
62 __import__(test)
63 passed = 1
64 except KeyboardInterrupt:
65 """This allows us to abort the testing manually using Ctrl-C."""
66 raise
67 except SystemExit as e:
68 """This is the regular way our test scripts are supposed to report
69 test failures."""
70 if e.code is None or e.code == 0:
71 passed = 1
72 except:
73 exc_type, exc_value, exc_tb = sys.exc_info()
74 try:
75 BoostBuild.annotation("failure - unhandled exception", "%s - "
76 "%s" % (exc_type.__name__, exc_value))
77 BoostBuild.annotate_stack_trace(exc_tb)
78 finally:
79 # Explicitly clear a hard-to-garbage-collect traceback
80 # related reference cycle as per documented sys.exc_info()
81 # usage suggestion.
82 del exc_tb
83
84 if passed:
85 pass_count += 1
86 else:
87 failures_count += 1
88 if failures_count == 1:
89 f = open(os.path.join(invocation_dir, "test_results.txt"), "w")
90 try:
91 f.write(test)
92 finally:
93 f.close()
94
95 # Restore the current directory, which might have been changed by the
96 # test.
97 os.chdir(invocation_dir)
98
99 if not xml:
100 if passed:
101 print("PASSED")
102 else:
103 print("FAILED")
104 BoostBuild.flush_annotations()
105 else:
106 rs = "succeed"
107 if not passed:
108 rs = "fail"
109 print('''
110 <test-log library="build" test-name="%s" test-type="run" toolset="%s" test-program="%s" target-directory="%s">
111 <run result="%s">''' % (test, toolset, "tools/build/v2/test/" + test + ".py",
112 "boost/bin.v2/boost.build.tests/" + toolset + "/" + test, rs))
113 if not passed:
114 BoostBuild.flush_annotations(1)
115 print('''
116 </run>
117 </test-log>
118 ''')
119 sys.stdout.flush() # Makes testing under emacs more entertaining.
120 BoostBuild.clear_annotations()
121
122 # Erase the file on success.
123 if failures_count == 0:
124 open("test_results.txt", "w").close()
125
126 if not xml:
127 print('''
128 === Test summary ===
129 PASS: %d
130 FAIL: %d
131 ''' % (pass_count, failures_count))
132
133 # exit with failure with failures
134 if failures_count > 0:
135 sys.exit(1)
136
137 def last_failed_test():
138 "Returns the name of the last failed test or None."
139 try:
140 f = open("test_results.txt")
141 try:
142 return f.read().strip()
143 finally:
144 f.close()
145 except Exception:
146 return None
147
148
149 def reorder_tests(tests, first_test):
150 try:
151 n = tests.index(first_test)
152 return [first_test] + tests[:n] + tests[n + 1:]
153 except ValueError:
154 return tests
155
156
157 critical_tests = ["unit_tests", "module_actions", "startup_v2", "core_d12",
158 "core_typecheck", "core_delete_module", "core_language", "core_arguments",
159 "core_varnames", "core_import_module"]
160
161 # We want to collect debug information about the test site before running any
162 # of the tests, but only when not running the tests interactively. Then the
163 # user can easily run this always-failing test directly to see what it would
164 # have returned and there is no need to have it spoil a possible 'all tests
165 # passed' result.
166 if xml:
167 critical_tests.insert(0, "collect_debug_info")
168
169 tests = ["abs_workdir",
170 "absolute_sources",
171 "alias",
172 "alternatives",
173 "always",
174 "bad_dirname",
175 "build_dir",
176 "build_file",
177 "build_hooks",
178 "build_no",
179 "builtin_echo",
180 "builtin_exit",
181 "builtin_glob",
182 "builtin_readlink",
183 "builtin_split_by_characters",
184 "bzip2",
185 "c_file",
186 "chain",
187 "clean",
188 "cli_property_expansion",
189 "command_line_properties",
190 "composite",
191 "conditionals",
192 "conditionals2",
193 "conditionals3",
194 "conditionals4",
195 "conditionals_multiple",
196 "configuration",
197 "configure",
198 "copy_time",
199 "core_action_output",
200 "core_action_status",
201 "core_actions_quietly",
202 "core_at_file",
203 "core_bindrule",
204 "core_dependencies",
205 "core_syntax_error_exit_status",
206 "core_fail_expected",
207 "core_jamshell",
208 "core_modifiers",
209 "core_multifile_actions",
210 "core_nt_cmd_line",
211 "core_option_d2",
212 "core_option_l",
213 "core_option_n",
214 "core_parallel_actions",
215 "core_parallel_multifile_actions_1",
216 "core_parallel_multifile_actions_2",
217 "core_scanner",
218 "core_source_line_tracking",
219 "core_update_now",
220 "core_variables_in_actions",
221 "custom_generator",
222 "debugger",
223 # Newly broken?
224 # "debugger-mi",
225 "default_build",
226 "default_features",
227 # This test is known to be broken itself.
228 # "default_toolset",
229 "dependency_property",
230 "dependency_test",
231 "disambiguation",
232 "dll_path",
233 "double_loading",
234 "duplicate",
235 "example_libraries",
236 "example_make",
237 "exit_status",
238 "expansion",
239 "explicit",
240 "feature_cxxflags",
241 "feature_implicit_dependency",
242 "feature_relevant",
243 "feature_suppress_import_lib",
244 "file_types",
245 "flags",
246 "generator_selection",
247 "generators_test",
248 "implicit_dependency",
249 "indirect_conditional",
250 "inherit_toolset",
251 "inherited_dependency",
252 "inline",
253 "install_build_no",
254 "libjpeg",
255 "liblzma",
256 "libpng",
257 "libtiff",
258 "libzstd",
259 "lib_source_property",
260 "lib_zlib",
261 "library_chain",
262 "library_property",
263 "link",
264 "load_order",
265 "loop",
266 "make_rule",
267 "message",
268 "ndebug",
269 "no_type",
270 "notfile",
271 "ordered_include",
272 # FIXME: Disabled due to bug in B2
273 # "ordered_properties",
274 "out_of_tree",
275 "package",
276 "param",
277 "path_features",
278 "prebuilt",
279 "preprocessor",
280 "print",
281 "project_dependencies",
282 "project_glob",
283 "project_id",
284 "project_root_constants",
285 "project_root_rule",
286 "project_test3",
287 "project_test4",
288 "property_expansion",
289 # FIXME: Disabled due lack of qt5 detection
290 # "qt5",
291 "rebuilds",
292 "relative_sources",
293 "remove_requirement",
294 "rescan_header",
295 "resolution",
296 "rootless",
297 "scanner_causing_rebuilds",
298 "searched_lib",
299 "skipping",
300 "sort_rule",
301 "source_locations",
302 "source_order",
303 "space_in_path",
304 "stage",
305 "standalone",
306 "static_and_shared_library",
307 "suffix",
308 "tag",
309 "test_rc",
310 "test1",
311 "test2",
312 "testing",
313 "timedata",
314 "toolset_clang_darwin",
315 "toolset_clang_linux",
316 "toolset_clang_vxworks",
317 "toolset_darwin",
318 "toolset_defaults",
319 "toolset_gcc",
320 "toolset_intel_darwin",
321 "toolset_msvc",
322 "toolset_requirements",
323 "transitive_skip",
324 "unit_test",
325 "unused",
326 "use_requirements",
327 "using",
328 "wrapper",
329 "wrong_project",
330 ]
331
332 if os.name == "posix":
333 tests.append("symlink")
334 # On Windows, library order is not important, so skip this test. Besides,
335 # it fails ;-). Further, the test relies on the fact that on Linux, one can
336 # build a shared library with unresolved symbols. This is not true on
337 # Windows, even with cygwin gcc.
338
339 # Disable this test until we figure how to address failures due to --as-needed being default now.
340 # if "CYGWIN" not in os.uname()[0]:
341 # tests.append("library_order")
342
343 if toolset.startswith("gcc") and os.name != "nt":
344 # On Windows it's allowed to have a static runtime with gcc. But this test
345 # assumes otherwise. Hence enable it only when not on Windows.
346 tests.append("gcc_runtime")
347
348 if toolset.startswith("clang") or toolset.startswith("gcc") or toolset.startswith("msvc"):
349 tests.append("pch")
350 if sys.platform != "darwin": # clang-darwin does not yet support
351 tests.append("feature_force_include")
352
353 # Clang includes Objective-C driver everywhere, but GCC usually in a separate gobj package
354 if toolset.startswith("clang") or "darwin" in toolset:
355 tests.append("lang_objc")
356
357 # Disable on OSX as it doesn't seem to work for unknown reasons.
358 if sys.platform != 'darwin':
359 tests.append("builtin_glob_archive")
360
361 if "--extras" in sys.argv:
362 tests.append("boostbook")
363 tests.append("qt4")
364 tests.append("qt5")
365 tests.append("example_qt4")
366 # Requires ./whatever.py to work, so is not guaranteed to work everywhere.
367 tests.append("example_customization")
368 # Requires gettext tools.
369 tests.append("example_gettext")
370 elif not xml:
371 print("Note: skipping extra tests")
372
373 run_tests(critical_tests, tests)