testglobals.py 7.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 
# (c) Simon Marlow 2002
#

# -----------------------------------------------------------------------------
# Configuration info

# There is a single global instance of this structure, stored in the
# variable config below.  The fields of the structure are filled in by
# the appropriate config script(s) for this compiler/platform, in
# ../config.
# 
# Bits of the structure may also be filled in from the command line,
# via the build system, using the '-e' option to runtests.

class TestConfig:
    def __init__(self):

19
20
21
        # Where the testsuite root is
        self.top = ''

22
23
        # Directories below which to look for test description files (foo.T)
        self.rootdirs = []
24
25
26
27
28
29
30
31
32
33

        # Run these tests only (run all tests if empty)
        self.only = []

        # Accept new output which differs from the sample?
        self.accept = 0

        # File in which to save the summary
        self.output_summary = ''

34
35
36
        # File in which to save the times
        self.times_file = ''

37
38
        # What platform are we running on?
        self.platform = ''
39
        self.os = ''
40
        self.arch = ''
41
42
43
44
45

        # What is the wordsize (in bits) of this platform?
        self.wordsize = ''

        # Verbosity level
46
        self.verbose = 3
47
48
49
50

        # run the "fast" version of the test suite
        self.fast = 0

ian@well-typed.com's avatar
ian@well-typed.com committed
51
52
        self.list_broken = False

53
54
55
56
57
        # Compiler type (ghc, hugs, nhc, etc.)
        self.compiler_type = ''

        # Path to the compiler
        self.compiler = ''
58
59
        # and ghc-pkg
        self.ghc_pkg = ''
60

61
62
        # Compiler version info
        self.compiler_version = ''
63
        self.compiler_maj_version = ''
64
65
        self.compiler_tags = []

66
67
68
69
70
71
72
73
        # Flags we always give to this compiler
        self.compiler_always_flags = []
        
        # Which ways to run tests (when compiling and running respectively)
        # Other ways are added from the command line if we have the appropriate
        # libraries.
        self.compile_ways = []
        self.run_ways     = []
74
75
76
77
        self.other_ways   = []

        # The ways selected via the command line.
        self.cmdline_ways = []
78
79
80
81
82

        # Lists of flags for each way
        self.way_flags = {}
        self.way_rts_flags = {}

83
84
85
        # Do we have vanilla libraries?
        self.have_vanilla = False

86
87
88
        # Do we have dynamic libraries?
        self.have_dynamic = False

89
90
91
        # Do we have profiling support?
        self.have_profiling = False

Ian Lynagh's avatar
Ian Lynagh committed
92
93
94
        # Do we have interpreter support?
        self.have_interp = False

Simon Marlow's avatar
Simon Marlow committed
95
96
97
        # Do we have shared libraries?
        self.have_shared_libs = False

Simon Marlow's avatar
Simon Marlow committed
98
99
100
        # Do we have SMP support?
        self.have_smp = False

101
102
103
        # Are we testing an in-tree compiler?
        self.in_tree_compiler = True

104
105
106
107
108
109
        # the timeout program
        self.timeout_prog = ''
        self.timeout = 300
        
        # threads
        self.threads = 1
110
        self.use_threads = 0
111

112
113
114
        # Should we check for files being written more than once?
        self.check_files_written = False

115
116
117
        # Should we skip performance tests
        self.skip_perf_tests = False

118
119
120
121
122
123
124
125
126
127
128
global config
config = TestConfig()

def getConfig():
    return config

# -----------------------------------------------------------------------------
# Information about the current test run

class TestRun:
   def __init__(self):
129
       self.start_time = None
130
131
132
133
134
135
136
137
138
139
       self.total_tests = 0
       self.total_test_cases = 0
       self.n_framework_failures = 0
       self.framework_failures = {}
       self.n_tests_skipped = 0
       self.tests_skipped = {}
       self.n_expected_passes = 0
       self.expected_passes = {}
       self.n_expected_failures = 0
       self.expected_failures = {}
140
141
       self.n_missing_libs = 0
       self.missing_libs = {}
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
       self.n_unexpected_passes = 0
       self.unexpected_passes = {}
       self.n_unexpected_failures = 0
       self.unexpected_failures = {}
       
global t
t = TestRun()

def getTestRun():
    return t

# -----------------------------------------------------------------------------
# Information about the current test

class TestOptions:
   def __init__(self):
158
159
       # if not None then we look for namebase.stderr etc rather than
       # using the test name
160
       self.with_namebase = None
161

162
       # skip this test?
163
       self.skip = 0
164
165
166
167

       # skip these ways
       self.omit_ways = []

168
169
       # skip all ways except these (None == do all ways)
       self.only_ways = None
170

171
172
173
       # add these ways to the default set
       self.extra_ways = []

174
       # the result we normally expect for this test
175
       self.expect = 'pass'
176
177

       # override the expected result for certain ways
178
       self.expect_fail_for = []
179
180
181
182

       # the stdin file that this test will use (empty for <name>.stdin)
       self.stdin = ''

183
184
185
       # don't compare output
       self.ignore_output = 0

186
187
188
       # don't give anything as stdin
       self.no_stdin = 0

189
190
191
       # compile this test to .hc only
       self.compile_to_hc = 0

192
193
194
195
196
       # We sometimes want to modify the compiler_always_flags, so
       # they are copied from config.compiler_always_flags when we
       # make a new instance of TestOptions.
       self.compiler_always_flags = []

197
198
199
200
201
202
203
204
205
206
207
208
       # extra compiler opts for this test
       self.extra_hc_opts = ''

       # extra run opts for this test
       self.extra_run_opts = ''

       # expected exit code
       self.exit_code = 0

       # should we clean up after ourselves?
       self.cleanup = ''

209
210
211
       # extra files to clean afterward
       self.clean_files = []

212
213
214
215
216
217
218
219
220
221
       # which -t numeric fields do we want to look at, and what bounds must
       # they fall within?
       # Elements of these lists should be things like
       # ('bytes allocated',
       #   9300000000,
       #   10)
       # To allow a 10% deviation from 9300000000.
       self.compiler_stats_range_fields = {}
       self.stats_range_fields = {}

222
223
       # should we run this test alone, i.e. not run it in parallel with
       # any other threads
224
       self.alone = False
225

Ian Lynagh's avatar
Ian Lynagh committed
226
227
228
       # Does this test use a literate (.lhs) file?
       self.literate = 0

229
230
231
232
       # Does this test use a .c, .m or .mm file?
       self.c_src      = 0
       self.objc_src   = 0
       self.objcpp_src = 0
233

234
235
236
       # Does this test use a .cmm file?
       self.cmm_src    = 0

237
238
239
       # Should we put .hi/.o files in a subdirectory?
       self.outputdir = None

240
241
242
       # Command to run before the test
       self.pre_cmd = None

243
244
245
       # Command to run for extra cleaning
       self.clean_cmd = None

246
247
       # Command wrapper: a function to apply to the command before running it
       self.cmd_wrapper = None
248

Ian Lynagh's avatar
Ian Lynagh committed
249
250
251
       # Prefix to put on the command before compiling it
       self.compile_cmd_prefix = ''

252
253
254
       # Extra output normalisation
       self.extra_normaliser = lambda x: x

255
256
257
258
259
       # Custom output checker, otherwise do a comparison with expected
       # stdout file.  Accepts two arguments: filename of actual stdout
       # output, and a normaliser function given other test options
       self.check_stdout = None

260
261
262
       # Extra normalisation for compiler error messages
       self.extra_errmsg_normaliser = lambda x: x

263
264
265
       # The directory the test is in
       self.testdir = '.'

pcapriotti's avatar
pcapriotti committed
266
267
268
       # Should we redirect stdout and stderr to a single file?
       self.combined_output = False

269
270
271
       # How should the timeout be adjusted on this test?
       self.timeout_multiplier = 1.0

272
273
274
275
# The default set of options
global default_testopts
default_testopts = TestOptions()

276
# (bug, directory, name) of tests marked broken
ian@well-typed.com's avatar
ian@well-typed.com committed
277
278
279
global brokens
brokens = []