File: test_all.py

package info (click to toggle)
boost-build 2.0-m12-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 8,692 kB
  • ctags: 6,963
  • sloc: ansic: 39,914; sh: 9,086; python: 6,120; xml: 5,524; cpp: 1,467; yacc: 456; asm: 353; makefile: 184
file content (197 lines) | stat: -rw-r--r-- 5,507 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/python

# Copyright 2002-2005 Dave Abrahams.
# Copyright 2002-2006 Vladimir Prus.
# Distributed under the Boost Software License, Version 1.0.
#    (See accompanying file LICENSE_1_0.txt or copy at
#         http://www.boost.org/LICENSE_1_0.txt)

import os, sys, string
import BoostBuild
from BoostBuild import get_toolset

# clear environment for testing
#
for s in (
    'BOOST_ROOT','BOOST_BUILD_PATH','JAM_TOOLSET','BCCROOT',
    'MSVCDir','MSVC','MSVCNT','MINGW','watcom'
    ):
    
    try:
        del os.environ[s]
    except:
        pass

BoostBuild.set_defer_annotations(1)    

def run_tests(critical_tests, other_tests):
    """Runs first critical tests and then other_tests.

       Stops on first error, and write the name of failed test to
       test_results.txt. Critical tests are run in the specified order,
       other tests are run starting with the one that failed the last time.
    """
    last_failed = last_failed_test()
    other_tests = reorder_tests(other_tests, last_failed)
    all_tests = critical_tests + other_tests

    invocation_dir = os.getcwd()

    pass_count = 0
    failures_count = 0
    for i in all_tests:
        print ("%-25s : " %(i)),
        try:
            __import__(i)
        except SystemExit:
            print "FAILED"
            if failures_count == 0:
                f = open(os.path.join(invocation_dir, 'test_results.txt'), 'w')
                f.write(i)
                f.close()
            failures_count = failures_count + 1
            # Restore the current directory, which might be changed by the
            # test
            os.chdir(invocation_dir)
            BoostBuild.flush_annotations();
            continue
        print "PASSED"
        BoostBuild.flush_annotations();
        pass_count = pass_count + 1
        sys.stdout.flush()  # makes testing under emacs more entertaining.
        
    # Erase the file on success
    if failures_count == 0:
        open('test_results.txt', 'w')

    print """
    === Test summary ===
    PASS: %d
    FAIL: %d
    """ % (pass_count, failures_count)
        

def last_failed_test():
    "Returns the name of last failed test or None"
    try:
        f = open("test_results.txt")
        s = string.strip(f.read())
        return s
    except:
        return None

def reorder_tests(tests, first_test):
    try:
        n = tests.index(first_test)
        return [first_test] + tests[:n] + tests[n+1:]
    except ValueError:
        return tests

            
critical_tests = ["unit_tests", "module_actions", "startup_v1", "startup_v2"]

critical_tests += ["core_d12", "core_typecheck", "core_delete_module",
                   "core_varnames", "core_import_module"]

tests = [ "rebuilds",
          "timedata",
          "project_test3",
          "project_test4",
          "generators_test",
          "dependency_test",
          "path_features",
          "relative_sources",
          "no_type",
          "chain",
          "default_build",
          "use_requirements",
          "conditionals",
          "stage",
          "prebuilt",
          "project_dependencies",
          "build_dir",
          "searched_lib",
          "make_rule",
          "alias",
          "alternatives",
          "default_features",
          "print",
          "ndebug",
          "explicit",
          "absolute_sources",
          "dependency_property",
          "custom_generator",
          "bad_dirname",
          "c_file",
          "inline",
          "conditionals2",
          "property_expansion",
          "loop",
          "conditionals3",
          "tag",
          "suffix",
          "inherit_toolset",
          "skipping",
          "project_glob",
          "project_root_constants",
          "double_loading",
          "dll_path",
          "regression",
          "composite",
          "library_chain",
          "unit_test",
          "standalone",
          "expansion",
          "wrapper",
          "duplicate",
          "library_property",
          "load_order",
          "wrong_project",
          "using",
          "source_locations",
          "out_of_tree",
          "notfile",
          "project_root_rule",
          "resolution",
          "build_file",
          "indirect_conditional",
          "build_no",
          "disambiguation",
          "clean",
          "lib_source_property",
          "implicit_dependency",
          "example_libraries",
          "example_make",
          "remove_requirement",
          "free_features_request",
          ]

if os.name == 'posix':
    tests.append("symlink")
    # On windows, library order is not important, so skip this test
    # Besides, it fails ;-)
    # Further, the test relies on the fact that on Linux, one
    # can build a shared library with unresolved symbols. This is
    # not true on Windows (even with cygwin gcc).
    if string.find(os.uname()[0], "CYGWIN") == -1:
        tests.append("library_order")

if string.find(get_toolset(), 'gcc') == 0:
    tests.append("gcc_runtime")

if string.find(get_toolset(), 'gcc') == 0 or string.find(get_toolset(), 'msvc') == 0:
    tests.append("pch")

if "--extras" in sys.argv:
    tests.append("boostbook")
    tests.append("example_qt4")
    # Requires ./whatever.py to work, so is
    # not guaranted to work everywhere.
    tests.append("example_customization")
    # Requires gettext tools.
    tests.append("example_gettext")
    
else:
    print 'Note: skipping extra tests'

run_tests(critical_tests, tests)