Fix #13839: GHCi warnings do not respect the default module header
[ghc.git] / testsuite / driver / testglobals.py
1 #
2 # (c) Simon Marlow 2002
3 #
4
5 # -----------------------------------------------------------------------------
6 # Configuration info
7
8 # There is a single global instance of this structure, stored in the
9 # variable config below. The fields of the structure are filled in by
10 # the appropriate config script(s) for this compiler/platform, in
11 # ../config.
12 #
13 # Bits of the structure may also be filled in from the command line,
14 # via the build system, using the '-e' option to runtests.
15
16 class TestConfig:
17 def __init__(self):
18
19 # Where the testsuite root is
20 self.top = ''
21
22 # Directories below which to look for test description files (foo.T)
23 self.rootdirs = []
24
25 # Run these tests only (run all tests if empty)
26 self.run_only_some_tests = False
27 self.only = set()
28
29 # Accept new output which differs from the sample?
30 self.accept = False
31 self.accept_platform = False
32 self.accept_os = False
33
34 # File in which to save the performance metrics.
35 self.metrics_file = ''
36
37 # File in which to save the summary
38 self.summary_file = ''
39
40 # Should we print the summary?
41 # Disabling this is useful for Phabricator/Harbormaster
42 # logfiles, which are truncated to 30 lines. TODO. Revise if
43 # this is still true.
44 # Note that we have a separate flag for this, instead of
45 # overloading --verbose, as you might want to see the summary
46 # with --verbose=0.
47 self.no_print_summary = False
48
49 # What platform are we running on?
50 self.platform = ''
51 self.os = ''
52 self.arch = ''
53 self.msys = False
54 self.cygwin = False
55
56 # What is the wordsize (in bits) of this platform?
57 self.wordsize = ''
58
59 # Verbosity level
60 self.verbose = 3
61
62 # See Note [validate and testsuite speed] in toplevel Makefile.
63 self.speed = 1
64
65 self.list_broken = False
66
67 # Path to the compiler (stage2 by default)
68 self.compiler = ''
69 # and ghc-pkg
70 self.ghc_pkg = ''
71
72 # Is self.compiler a stage 1, 2 or 3 compiler?
73 self.stage = 2
74
75 # Flags we always give to this compiler
76 self.compiler_always_flags = []
77
78 # Which ways to run tests (when compiling and running respectively)
79 # Other ways are added from the command line if we have the appropriate
80 # libraries.
81 self.compile_ways = []
82 self.run_ways = []
83 self.other_ways = []
84
85 # The ways selected via the command line.
86 self.cmdline_ways = []
87
88 # Lists of flags for each way
89 self.way_flags = {}
90 self.way_rts_flags = {}
91
92 # Do we have vanilla libraries?
93 self.have_vanilla = False
94
95 # Do we have dynamic libraries?
96 self.have_dynamic = False
97
98 # Do we have profiling support?
99 self.have_profiling = False
100
101 # Do we have interpreter support?
102 self.have_interp = False
103
104 # Do we have shared libraries?
105 self.have_shared_libs = False
106
107 # Do we have SMP support?
108 self.have_smp = False
109
110 # Is gdb avaliable?
111 self.have_gdb = False
112
113 # Is readelf available?
114 self.have_readelf = False
115
116 # Are we testing an in-tree compiler?
117 self.in_tree_compiler = True
118
119 # the timeout program
120 self.timeout_prog = ''
121 self.timeout = 300
122
123 # threads
124 self.threads = 1
125 self.use_threads = False
126
127 # Should we skip performance tests
128 self.skip_perf_tests = False
129
130 # Only do performance tests
131 self.only_perf_tests = False
132
133 # Allowed performance changes (see perf_notes.get_allowed_perf_changes())
134 self.allowed_perf_changes = {}
135
136 # The test environment.
137 self.test_env = 'local'
138
139 global config
140 config = TestConfig()
141
142 def getConfig():
143 return config
144
145 import os
146 # Hold our modified GHC testrunning environment so we don't poison the current
147 # python's environment.
148 global ghc_env
149 ghc_env = os.environ.copy()
150
151 # -----------------------------------------------------------------------------
152 # Information about the current test run
153
154 class TestResult:
155 """
156 A result from the execution of a test. These live in the expected_passes,
157 framework_failures, framework_warnings, unexpected_passes,
158 unexpected_failures, unexpected_stat_failures lists of TestRun.
159 """
160 __slots__ = 'directory', 'testname', 'reason', 'way', 'stderr'
161 def __init__(self, directory, testname, reason, way, stderr=None):
162 self.directory = directory
163 self.testname = testname
164 self.reason = reason
165 self.way = way
166 self.stderr = stderr
167
168 class TestRun:
169 def __init__(self):
170 self.start_time = None
171 self.total_tests = 0
172 self.total_test_cases = 0
173
174 self.n_tests_skipped = 0
175 self.n_expected_passes = 0
176 self.n_expected_failures = 0
177
178 # type: List[TestResult]
179 self.missing_libs = []
180 self.framework_failures = []
181 self.framework_warnings = []
182
183 self.expected_passes = []
184 self.unexpected_passes = []
185 self.unexpected_failures = []
186 self.unexpected_stat_failures = []
187
188 # List of all metrics measured in this test run.
189 # [(change, PerfStat)] where change is one of the MetricChange
190 # constants: NewMetric, NoChange, Increase, Decrease.
191 # NewMetric happens when the previous git commit has no metric recorded.
192 self.metrics = []
193
194 global t
195 t = TestRun()
196
197 def getTestRun():
198 return t
199
200 # -----------------------------------------------------------------------------
201 # Information about the current test
202
203 class TestOptions:
204 def __init__(self):
205 # skip this test?
206 self.skip = False
207
208 # skip these ways
209 self.omit_ways = []
210
211 # skip all ways except these (None == do all ways)
212 self.only_ways = None
213
214 # add these ways to the default set
215 self.extra_ways = []
216
217 # the result we normally expect for this test
218 self.expect = 'pass'
219
220 # override the expected result for certain ways
221 self.expect_fail_for = []
222
223 # the stdin file that this test will use (empty for <name>.stdin)
224 self.stdin = ''
225
226 # Set the expected stderr/stdout. '' means infer from test name.
227 self.use_specs = {}
228
229 # don't compare output
230 self.ignore_stdout = False
231 self.ignore_stderr = False
232
233 # Backpack test
234 self.compile_backpack = False
235
236 # We sometimes want to modify the compiler_always_flags, so
237 # they are copied from config.compiler_always_flags when we
238 # make a new instance of TestOptions.
239 self.compiler_always_flags = []
240
241 # extra compiler opts for this test
242 self.extra_hc_opts = ''
243
244 # extra run opts for this test
245 self.extra_run_opts = ''
246
247 # expected exit code
248 self.exit_code = 0
249
250 # extra files to clean afterward
251 self.clean_files = []
252
253 # extra files to copy to the testdir
254 self.extra_files = []
255
256 # Map from metric to (function from way and commit to baseline value, allowed percentage deviation) e.g.
257 # { 'bytes allocated': (
258 # lambda way commit:
259 # ...
260 # if way1: return None ...
261 # elif way2:return 9300000000 ...
262 # ...
263 # , 10) }
264 # This means no baseline is available for way1. For way 2, allow a 10%
265 # deviation from 9300000000.
266 self.stats_range_fields = {}
267
268 # Is the test testing performance?
269 self.is_stats_test = False
270
271 # Does this test the compiler's performance as opposed to the generated code.
272 self.is_compiler_stats_test = False
273
274 # should we run this test alone, i.e. not run it in parallel with
275 # any other threads
276 self.alone = False
277
278 # Does this test use a literate (.lhs) file?
279 self.literate = False
280
281 # Does this test use a .c, .m or .mm file?
282 self.c_src = False
283 self.objc_src = False
284 self.objcpp_src = False
285
286 # Does this test use a .cmm file?
287 self.cmm_src = False
288
289 # Should we put .hi/.o files in a subdirectory?
290 self.outputdir = None
291
292 # Command to run before the test
293 self.pre_cmd = None
294
295 # Command wrapper: a function to apply to the command before running it
296 self.cmd_wrapper = None
297
298 # Prefix to put on the command before compiling it
299 self.compile_cmd_prefix = ''
300
301 # Extra output normalisation
302 self.extra_normaliser = lambda x: x
303
304 # Custom output checker, otherwise do a comparison with expected
305 # stdout file. Accepts two arguments: filename of actual stdout
306 # output, and a normaliser function given other test options
307 self.check_stdout = None
308
309 # Check .hp file when profiling libraries are available?
310 self.check_hp = True
311
312 # Extra normalisation for compiler error messages
313 self.extra_errmsg_normaliser = lambda x: x
314
315 # Keep profiling callstacks.
316 self.keep_prof_callstacks = False
317
318 # The directory the test is in
319 self.testdir = '.'
320
321 # Should we redirect stdout and stderr to a single file?
322 self.combined_output = False
323
324 # How should the timeout be adjusted on this test?
325 self.compile_timeout_multiplier = 1.0
326 self.run_timeout_multiplier = 1.0
327
328 self.cleanup = True
329
330 # Sould we run tests in a local subdirectory (<testname>-run) or
331 # in temporary directory in /tmp? See Note [Running tests in /tmp].
332 self.local = True
333
334 # The default set of options
335 global default_testopts
336 default_testopts = TestOptions()
337
338 # (bug, directory, name) of tests marked broken
339 global brokens
340 brokens = []