Commit 97596a44 authored by Krzysztof Gogolewski's avatar Krzysztof Gogolewski

Simplify testsuite driver, part 2

Summary:
- Avoid import *; this helps tools such as pyflakes.
The last occurrence in runtests.py is not easy to remove
as it's used by .T files.
- Use False/True instead of 0/1.

Test Plan: validate

Reviewers: bgamari, thomie, simonmar

Reviewed By: thomie

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5062
parent f27d7145
......@@ -33,7 +33,7 @@ config.other_ways = ['prof', 'normal_h',
'ghci-ext', 'ghci-ext-prof',
'ext-interp']
if (ghc_with_native_codegen == 1):
if ghc_with_native_codegen:
config.compile_ways.append('optasm')
config.run_ways.append('optasm')
......@@ -44,25 +44,25 @@ if config.have_profiling:
if config.have_interp:
config.run_ways.append('ghci')
if (ghc_with_threaded_rts == 1):
if ghc_with_threaded_rts:
config.run_ways.append('threaded1')
if (ghc_with_smp == 1):
if ghc_with_smp:
config.have_smp = True
config.run_ways.append('threaded2')
if (ghc_with_dynamic_rts == 1):
if ghc_with_dynamic_rts:
config.have_shared_libs = True
if config.ghc_dynamic_by_default and config.have_vanilla == 1:
config.run_ways.append('static')
else:
if (ghc_with_dynamic_rts == 1):
if ghc_with_dynamic_rts:
config.run_ways.append('dyn')
if (config.have_profiling and ghc_with_threaded_rts == 1):
if (config.have_profiling and ghc_with_threaded_rts):
config.run_ways.append('profthreaded')
if (ghc_with_llvm == 1 and not config.unregisterised):
if (ghc_with_llvm and not config.unregisterised):
config.compile_ways.append('optllvm')
config.run_ways.append('optllvm')
......
......@@ -8,10 +8,12 @@ import argparse
import signal
import sys
import os
import io
import shutil
import tempfile
import time
import re
import traceback
# We don't actually need subprocess in runtests.py, but:
# * We do need it in testlibs.py
......@@ -21,8 +23,8 @@ import re
# So we import it here first, so that the testsuite doesn't appear to fail.
import subprocess
from testutil import *
from testglobals import *
from testutil import getStdout, Watcher
from testglobals import getConfig, ghc_env, getTestRun, TestOptions, brokens
from junit import junit
# Readline sometimes spews out ANSI escapes for some values of TERM,
......@@ -213,7 +215,6 @@ if windows or darwin:
# darwin
ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")])
global testopts_local
testopts_local.x = TestOptions()
# if timeout == -1 then we try to calculate a sensible value
......@@ -290,7 +291,6 @@ for name in config.only:
pass
if config.list_broken:
global brokens
print('')
print('Broken tests:')
print(' '.join(map (lambda bdn: '#' + str(bdn[0]) + '(' + bdn[1] + '/' + bdn[2] + ')', brokens)))
......
......@@ -18,8 +18,8 @@ from pathlib import PurePath
import collections
import subprocess
from testglobals import *
from testutil import *
from testglobals import config, ghc_env, default_testopts, brokens, t
from testutil import strip_quotes, lndir, link_or_copy_file
extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223
global pool_sema
......@@ -203,7 +203,6 @@ def _expect_broken_for( name, opts, bug, ways ):
opts.expect_fail_for = ways
def record_broken(name, opts, bug):
global brokens
me = (bug, opts.testdir, name)
if not me in brokens:
brokens.append(me)
......@@ -1563,7 +1562,7 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
# See Note [Output comparison].
if whitespace_normaliser(expected_str) == whitespace_normaliser(actual_str):
return 1
return True
else:
if config.verbose >= 1 and _expect_pass(way):
print('Actual ' + kind + ' output differs from expected:')
......@@ -1590,7 +1589,7 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
if config.accept and (getTestOpts().expect == 'fail' or
way in getTestOpts().expect_fail_for):
if_verbose(1, 'Test is expected to fail. Not accepting new output.')
return 0
return False
elif config.accept and actual_raw:
if config.accept_platform:
if_verbose(1, 'Accepting new output for platform "'
......@@ -1604,13 +1603,13 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
if_verbose(1, 'Accepting new output.')
write_file(expected_path, actual_raw)
return 1
return True
elif config.accept:
if_verbose(1, 'No output. Deleting "{0}".'.format(expected_path))
os.remove(expected_path)
return 1
return True
else:
return 0
return False
# Note [Output comparison]
#
......@@ -1866,7 +1865,7 @@ def gsNotWorking():
print("GhostScript not available for hp2ps tests")
global gs_working
gs_working = 0
gs_working = False
if config.have_profiling:
if config.gs != '':
resultGood = runCmd(genGSCmd(config.confdir + '/good.ps'));
......@@ -1875,7 +1874,7 @@ if config.have_profiling:
' >/dev/null 2>&1')
if resultBad != 0:
print("GhostScript available for hp2ps tests")
gs_working = 1;
gs_working = True
else:
gsNotWorking();
else:
......
......@@ -81,9 +81,9 @@ RUNTEST_OPTS += -e "ghc_compiler_always_flags='$(TEST_HC_OPTS)'"
RUNTEST_OPTS += -e config.compiler_debugged=$(GhcDebugged)
ifeq "$(GhcWithNativeCodeGen)" "YES"
RUNTEST_OPTS += -e ghc_with_native_codegen=1
RUNTEST_OPTS += -e ghc_with_native_codegen=True
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
RUNTEST_OPTS += -e ghc_with_native_codegen=False
endif
GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output))
......@@ -112,15 +112,15 @@ RUNTEST_OPTS += -e config.have_profiling=False
endif
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
RUNTEST_OPTS += -e ghc_with_threaded_rts=True
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
RUNTEST_OPTS += -e ghc_with_threaded_rts=False
endif
ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
RUNTEST_OPTS += -e ghc_with_dynamic_rts=True
else
RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
RUNTEST_OPTS += -e ghc_with_dynamic_rts=False
endif
ifeq "$(GhcWithInterpreter)" "NO"
......@@ -166,20 +166,20 @@ CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared
endif
ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1
RUNTEST_OPTS += -e ghc_with_smp=True
else
RUNTEST_OPTS += -e ghc_with_smp=0
RUNTEST_OPTS += -e ghc_with_smp=False
endif
ifeq "$(LLC)" ""
RUNTEST_OPTS += -e ghc_with_llvm=0
RUNTEST_OPTS += -e ghc_with_llvm=False
else ifeq "$(TargetARCH_CPP)" "powerpc"
RUNTEST_OPTS += -e ghc_with_llvm=0
RUNTEST_OPTS += -e ghc_with_llvm=False
else ifneq "$(LLC)" "llc"
# If we have a real detected value for LLVM, then it really ought to work
RUNTEST_OPTS += -e ghc_with_llvm=1
RUNTEST_OPTS += -e ghc_with_llvm=True
else
RUNTEST_OPTS += -e ghc_with_llvm=0
RUNTEST_OPTS += -e ghc_with_llvm=False
endif
ifeq "$(WINDOWS)" "YES"
......
# Test for bug #713, results in crashes in GHC prior to 20060315 with +RTS -N2
# Add 'threaded2_hT' so that we have at least one test for bug #5127
if (ghc_with_threaded_rts == 1 and ghc_with_smp == 1):
if ghc_with_threaded_rts and ghc_with_smp:
ways = ['threaded2_hT']
else:
ways = []
......
......@@ -175,14 +175,14 @@ def checkDynAsm(actual_file, normaliser):
actual_str = normaliser(actual_raw)
actual = actual_str.split()
if actual == ['initArray1', 'initArray2', 'success']:
return 1
return True
elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
return 1
return True
elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
return 1
return True
else:
if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
return 0
return False
# T5435_v_asm got split into two tests because depending
# on the linker, .init_array and .ctors sections are loaded
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment