Commit 206b4a1d authored by thomie's avatar thomie

Testsuite: simplify extra_file handling

Before, `extra_files(['.hpc/Main.mix'])` meant copy `Main.mix` to
`<testdir>/.hpc/Main.mix`. This feature wasn't really necessary, so now
it just means copy `Main.mix` to `<testdir>/Main.mix`. This simplifies
the implementation.

Some small other cleanups as well. -40 lines of code.
parent 1f45bce0
......@@ -46,8 +46,8 @@ extra_src_files = {
'T10420': ['rule-defining-plugin/'],
'T10458': ['A.c'],
'T10529a': ['hpc_sample_non_existing_module.tix'],
'T10529b': ['.hpc/Main.mix', 'hpc_sample_incompatible_hash.tix'],
'T10529c': ['.hpc/NoParse.mix', 'hpc_sample_no_parse.tix'],
'T10529b': ['.hpc/', 'hpc_sample_incompatible_hash.tix'],
'T10529c': ['.hpc/', 'hpc_sample_no_parse.tix'],
'T10576a': ['T10576.hs'],
'T10576b': ['T10576.hs'],
'T10637': ['A.hs', 'A.hs-boot'],
......@@ -298,27 +298,27 @@ extra_src_files = {
'heapprof002': ['heapprof001.hs'],
'hist001': ['../Test3.hs'],
'hpc001': ['../'],
'hpc_draft': ['.hpc/Main.mix', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_draft': ['.hpc/', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_fork': ['../'],
'hpc_ghc_ghci': ['A.hs', 'B.hs'],
'hpc_hand_overlay': ['.hpc/Main.mix', 'hand_overlay.ovr', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_markup_001': ['.hpc/Main.mix', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_markup_002': ['.hpc/Main.mix', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_hand_overlay': ['.hpc/', 'hand_overlay.ovr', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_markup_001': ['.hpc/', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_markup_002': ['.hpc/', 'hpc001.hs', 'hpc_sample.tix'],
'hpc_markup_multi_001': ['../Geometry.hs', '.hpc/', 'hpc_sample.tix'],
'hpc_markup_multi_002': ['../CSG.hs', '../Construct.hs', '../Data.hs', '../Eval.hs', '../Geometry.hs', '../Illumination.hs', '../Intersections.hs', '../Interval.hs', '../Main.hs', '../Misc.hs', '../Parse.hs', '../Pixmap.hs', '../Primitives.hs', '../RayTrace.hs', '../Surface.hs', '.hpc/', 'hpc_sample.tix'],
'hpc_markup_multi_003': ['../CSG.hs', '../Construct.hs', '../Data.hs', '../Eval.hs', '../Geometry.hs', '../Illumination.hs', '../Intersections.hs', '../Interval.hs', '../Main.hs', '../Misc.hs', '../Parse.hs', '../Pixmap.hs', '../Primitives.hs', '../RayTrace.hs', '../Surface.hs', '.hpc/', 'hpc_sample.tix'],
'hpc_overlay': ['.hpc/Main.mix', 'hpc001.hs', 'hpc_sample.tix', 'sample_overlay.ovr'],
'hpc_overlay2': ['.hpc/Main.mix', 'hpc001.hs', 'hpc_sample.tix', 'sample_overlay.ovr'],
'hpc_overlay': ['.hpc/', 'hpc001.hs', 'hpc_sample.tix', 'sample_overlay.ovr'],
'hpc_overlay2': ['.hpc/', 'hpc001.hs', 'hpc_sample.tix', 'sample_overlay.ovr'],
'hpc_raytrace': ['../', 'CSG.hs', 'Construct.hs', 'Data.hs', 'Eval.hs', 'Geometry.hs', 'Illumination.hs', 'Intersections.hs', 'Interval.hs', 'Main.hs', 'Misc.hs', 'Parse.hs', 'Primitives.hs', 'Surface.hs', 'galois.gml', 'galois.sample'],
'hpc_report_001': ['.hpc/Main.mix', 'hpc_sample.tix'],
'hpc_report_002': ['.hpc/Main.mix', 'hpc_sample.tix'],
'hpc_report_003': ['.hpc/Main.mix', 'hpc_sample.tix'],
'hpc_report_multi_001': ['.hpc/Geometry.mix', 'hpc_sample.tix'],
'hpc_report_001': ['.hpc/', 'hpc_sample.tix'],
'hpc_report_002': ['.hpc/', 'hpc_sample.tix'],
'hpc_report_003': ['.hpc/', 'hpc_sample.tix'],
'hpc_report_multi_001': ['.hpc/', 'hpc_sample.tix'],
'hpc_report_multi_002': ['.hpc/', 'hpc_sample.tix'],
'hpc_report_multi_003': ['.hpc/Geometry.mix', 'hpc_sample.tix'],
'hpc_show': ['.hpc/Main.mix', 'hpc_sample.tix'],
'hpc_report_multi_003': ['.hpc/', 'hpc_sample.tix'],
'hpc_show': ['.hpc', 'hpc_sample.tix'],
'hpc_show_multi_001': ['.hpc/', 'hpc_sample.tix'],
'hpc_show_multi_002': ['.hpc/Geometry.mix', 'hpc_sample.tix'],
'hpc_show_multi_002': ['.hpc/', 'hpc_sample.tix'],
'hs-boot': ['A.hs', 'A.hs-boot', 'B.hs', 'C.hs', 'Main.hs'],
'impexp': ['Exp.hs', 'Imp.hs'],
'ind2': ['Ind2_help.hs'],
......@@ -64,7 +64,7 @@ def setLocalTestOpts(opts):
def isStatsTest():
opts = getTestOpts()
return len(opts.compiler_stats_range_fields) > 0 or len(opts.stats_range_fields) > 0
return bool(opts.compiler_stats_range_fields or opts.stats_range_fields)
# This can be called at the top of a file of tests, to set default test options
......@@ -791,6 +791,7 @@ def do_test(name, way, func, args, files):
# Clean up prior to the test, so that we can't spuriously conclude
# that it passed on the basis of old run outputs.
# Link all source files for this test into a new directory in
# /tmp, and run the test in that directory. This makes it
......@@ -800,39 +801,14 @@ def do_test(name, way, func, args, files):
for extra_file in files:
src = in_srcdir(extra_file)
if extra_file.startswith('..'):
# In case the extra_file is a file in an ancestor
# directory (e.g. extra_files(['../shell.hs'])), make
# sure it is copied to the test directory
# (testdir/shell.hs), instead of ending up somewhere
# else in the tree (testdir/../shell.hs)
filename = os.path.basename(extra_file)
filename = extra_file
assert not '..' in filename # no funny stuff (foo/../../bar)
dst = in_testdir(filename)
dst = in_testdir(os.path.basename(extra_file.rstrip('/\\')))
if os.path.isfile(src):
dirname = os.path.dirname(dst)
if dirname:
link_or_copy_file(src, dst)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isfile(dst):
# Some tests depend on files from ancestor
# directories (e.g. '../shell.hs'). It is
# possible such a file was already copied over
# for another test, since cleanup() doesn't
# delete them.
link_or_copy_file(src, dst)
elif os.path.isdir(src):
lndir(src, dst)
if not config.haddock and os.path.splitext(filename)[1] == '.t':
if not config.haddock and os.path.splitext(extra_file)[1] == '.t':
# When using a ghc built without haddock support, .t
# files are rightfully missing. Don't
# framework_fail. Test will be skipped later.
......@@ -841,12 +817,6 @@ def do_test(name, way, func, args, files):
framework_fail(name, way,
'extra_file does not exist: ' + extra_file)
if not files:
# Always create the testdir, even when no files were copied
# (because user forgot to specify extra_files setup function), to
# prevent the confusing error: can't cd to <testdir>.
if func.__name__ == 'run_command' or opts.pre_cmd:
# When running 'MAKE' make sure 'TOP' still points to the
# root of the testsuite.
......@@ -994,7 +964,6 @@ def run_command( name, way, cmd ):
def ghci_script( name, way, script):
flags = ' '.join(get_compiler_flags())
way_flags = ' '.join(config.way_flags[way])
# We pass HC and HC_OPTS as environment variables, so that the
......@@ -1121,7 +1090,7 @@ def checkStats(name, way, stats_file, range_fields):
full_name = name + '(' + way + ')'
result = passed()
if len(range_fields) > 0:
if range_fields:
f = open(in_testdir(stats_file))
except IOError as e:
......@@ -1151,10 +1120,6 @@ def checkStats(name, way, stats_file, range_fields):
result = failBecause('stat not good enough', tag='stat')
if val < lowerBound or val > upperBound or config.verbose >= 4:
valStr = str(val)
valLen = len(valStr)
expectedStr = str(expected)
expectedLen = len(expectedStr)
length = max(len(str(x)) for x in [expected, lowerBound, upperBound, val])
def display(descr, val, extra):
......@@ -1203,7 +1168,7 @@ def simple_build(name, way, extra_hc_opts, should_fail, top_mod, link, addsuf):
to_do = '-c' # just compile
stats_file = name + '.comp.stats'
if len(opts.compiler_stats_range_fields) > 0:
if opts.compiler_stats_range_fields:
extra_hc_opts += ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
# Required by GHC 7.3+, harmless for earlier versions:
......@@ -1275,7 +1240,7 @@ def simple_run(name, way, prog, extra_run_opts):
my_rts_flags = rts_flags(way)
stats_file = name + '.stats'
if len(opts.stats_range_fields) > 0:
if opts.stats_range_fields:
stats_args = ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
stats_args = ''
......@@ -1315,8 +1280,8 @@ def simple_run(name, way, prog, extra_run_opts):
return failBecause('bad exit code')
check_hp = my_rts_flags.find("-h") != -1
check_prof = my_rts_flags.find("-p") != -1
check_hp = '-h' in my_rts_flags
check_prof = '-p' in my_rts_flags
if not opts.ignore_output:
bad_stderr = not opts.combined_output and not check_stderr_ok(name, way)
......@@ -1334,15 +1299,8 @@ def simple_run(name, way, prog, extra_run_opts):
return checkStats(name, way, stats_file, opts.stats_range_fields)
def rts_flags(way):
if (way == ''):
return ''
args = config.way_rts_flags[way]
if args == []:
return ''
return '+RTS ' + ' '.join(args) + ' -RTS'
args = config.way_rts_flags.get(way, [])
return '+RTS {} -RTS'.format(' '.join(args)) if args else ''
# -----------------------------------------------------------------------------
# Run a program in the interpreter and check its output
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