Commit 8d34b5c7 authored by ian@well-typed.com's avatar ian@well-typed.com

Convert more helper functions

parent 7cc907d3
......@@ -348,75 +348,36 @@ def have_profiling( ):
# ---
def if_ghci_dynamic( f ):
if config.ghc_dynamic_by_default:
return f
else:
return normal
def ghci_dynamic( ):
return config.ghc_dynamic_by_default
def if_in_tree_compiler( f ):
if config.in_tree_compiler:
return f
else:
return normal
def in_tree_compiler( ):
return config.in_tree_compiler
def unless_in_tree_compiler( f ):
if config.in_tree_compiler:
return normal
else:
return f
def compiler_type( compiler ):
return config.compiler_type == compiler
def if_compiler_type( compiler, f ):
if config.compiler_type == compiler:
return f
else:
return normal
def compiler_profiled( ):
return config.compiler_profiled
def if_compiler_profiled( f ):
if config.compiler_profiled:
return f
else:
return normal
def compiler_lt( compiler, version ):
return config.compiler_type == compiler and \
version_lt(config.compiler_version, version)
def unless_compiler_profiled( f ):
if config.compiler_profiled:
return normal
else:
return f
def compiler_le( compiler, version ):
return config.compiler_type == compiler and \
version_le(config.compiler_version, version)
def if_compiler_lt( compiler, version, f ):
if config.compiler_type == compiler and \
version_lt(config.compiler_version, version):
return f
else:
return normal
def compiler_gt( compiler, version ):
return config.compiler_type == compiler and \
version_gt(config.compiler_version, version)
def if_compiler_le( compiler, version, f ):
if config.compiler_type == compiler and \
version_le(config.compiler_version, version):
return f
else:
return normal
def compiler_ge( compiler, version ):
return config.compiler_type == compiler and \
version_ge(config.compiler_version, version)
def if_compiler_gt( compiler, version, f ):
if config.compiler_type == compiler and \
version_gt(config.compiler_version, version):
return f
else:
return normal
def if_compiler_ge( compiler, version, f ):
if config.compiler_type == compiler and \
version_ge(config.compiler_version, version):
return f
else:
return normal
def if_compiler_debugged( f ):
if config.compiler_debugged:
return f
else:
return normal
def compiler_debugged( ):
return config.compiler_debugged
def namebase( nb ):
return lambda opts, nb=nb: _namebase(opts, nb)
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
# Annotations, like Template Haskell, require runtime evaluation. In
# order for this to work with profiling, we would have to build the
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
# These tests are very slow due to their use of package GHC
setTestOpts(skip_if_fast)
......
setTestOpts(only_compiler_types(['ghc']))
test('arrowfail001',
if_compiler_debugged(expect_broken(5267)),
when(compiler_debugged(), expect_broken(5267)),
compile_fail,
[''])
# arrowfail001 gets an ASSERT error in the stage1 compiler
......
......@@ -53,7 +53,7 @@ test('numsparks001', only_ways(['threaded1']), compile_and_run, [''])
test('T4262', [ skip, # skip for now, it doesn't give reliable results
only_ways(['threaded1']),
unless(opsys('linux'),skip),
if_compiler_lt('ghc', '7.1', expect_fail) ],
when(compiler_lt('ghc', '7.1'), expect_fail) ],
compile_and_run, [''])
test('T4813', normal, compile_and_run, [''])
......
......@@ -76,7 +76,7 @@ test('GadtOverlap', normal, compile, ['-Wall'])
test('T2395', normal, compile, [''])
test('T4371', normal, compile, [''])
test('T4439', normal, compile, [''])
test('T4488', if_compiler_lt('ghc', '7.1', expect_fail), compile, [''])
test('T4488', when(compiler_lt('ghc', '7.1'), expect_fail), compile, [''])
test('T4870',
[only_ways(['optasm']),
only_compiler_types(['ghc']),
......
......@@ -38,5 +38,5 @@ test('mc06', normal, compile_and_run, [''])
test('mc07', normal, compile_and_run, [''])
test('mc08', normal, compile_and_run, [''])
test('T5742', normal, compile_and_run, [''])
test('DsLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile_and_run, [''])
test('DsMultiWayIf', if_compiler_lt('ghc', '7.5', skip), compile_and_run, [''])
test('DsLambdaCase', when(compiler_lt('ghc', '7.5'), skip), compile_and_run, [''])
test('DsMultiWayIf', when(compiler_lt('ghc', '7.5'), skip), compile_and_run, [''])
......@@ -102,10 +102,10 @@ test('gadt25', normal, compile, [''])
test('T3651', normal, compile_fail, [''])
test('T3638', normal, compile, [''])
test('gadtSyntax001', if_compiler_lt('ghc', '7.1', expect_fail), compile, [''])
test('gadtSyntaxFail001', if_compiler_lt('ghc', '7.1', expect_fail), compile_fail, [''])
test('gadtSyntaxFail002', if_compiler_lt('ghc', '7.1', expect_fail), compile_fail, [''])
test('gadtSyntaxFail003', if_compiler_lt('ghc', '7.1', expect_fail), compile_fail, [''])
test('gadtSyntax001', when(compiler_lt('ghc', '7.1'), expect_fail), compile, [''])
test('gadtSyntaxFail001', when(compiler_lt('ghc', '7.1'), expect_fail), compile_fail, [''])
test('gadtSyntaxFail002', when(compiler_lt('ghc', '7.1'), expect_fail), compile_fail, [''])
test('gadtSyntaxFail003', when(compiler_lt('ghc', '7.1'), expect_fail), compile_fail, [''])
test('T3169', normal, compile_fail, [''])
test('T5424',
extra_clean(['T5424a.hi', 'T5424a.o']),
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('ghc-e001', req_interp, run_command, ['$MAKE --no-print-directory -s ghc-e001'])
test('ghc-e002', req_interp, run_command, ['$MAKE --no-print-directory -s ghc-e002'])
......@@ -8,7 +8,7 @@ test('ghc-e004', req_interp, run_command, ['$MAKE --no-print-directory -s ghc-e0
test('ghc-e005', req_interp, run_command, ['$MAKE --no-print-directory -s ghc-e005'])
test('T2228',
[req_interp, if_ghci_dynamic(expect_broken(7298))],
[req_interp, when(ghci_dynamic(), expect_broken(7298))],
run_command,
['$MAKE --no-print-directory -s T2228'])
test('T2636', req_interp, run_command, ['$MAKE --no-print-directory -s T2636'])
......
setTestOpts(composes([extra_run_opts('-ignore-dot-ghci'),
if_compiler_profiled(skip),
when(compiler_profiled(), skip),
normalise_slashes]))
test('print001', normal, ghci_script, ['print001.script'])
......@@ -36,7 +36,7 @@ test('print032', normal, ghci_script, ['print032.script'])
test('print033', normal, ghci_script, ['print033.script'])
test('print034', normal, ghci_script, ['print034.script'])
test('print035',
if_ghci_dynamic(expect_broken(7326)),
when(ghci_dynamic(), expect_broken(7326)),
ghci_script,
['print035.script'])
......
setTestOpts(extra_run_opts('-ignore-dot-ghci'))
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('break022', extra_clean(['A.hs']), ghci_script, ['break022.script'])
setTestOpts(extra_run_opts('-ignore-dot-ghci'))
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('break023', extra_clean(['A.hs']), ghci_script, ['break023.script'])
test('ghcilink001',
[if_ghci_dynamic(expect_fail), # dynamic ghci can't load '.a's
[when(ghci_dynamic(), expect_fail), # dynamic ghci can't load '.a's
skip_if_no_ghci,
extra_clean(['dir001/*','dir001'])],
run_command,
......@@ -21,7 +21,7 @@ test('ghcilink003',
['$MAKE -s --no-print-directory ghcilink003'])
test('ghcilink004',
[if_ghci_dynamic(expect_fail), # dynamic ghci can't load '.a's
[when(ghci_dynamic(), expect_fail), # dynamic ghci can't load '.a's
skip_if_no_ghci,
extra_clean(['dir004/*','dir004'])],
run_command,
......
# coding=utf8
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('ghci001', combined_output, ghci_script, ['ghci001.script'])
test('ghci002', combined_output, ghci_script, ['ghci002.script'])
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
# We only want to run these tests with GHCi
def just_ghci( name, opts ):
......
......@@ -159,7 +159,7 @@ test('T4484', normal, compile, [''])
test('T4492', normal, compile, [''])
test('T4494', normal, compile, [''])
test('DataFamDeriv', normal, compile, [''])
test('T1769', if_compiler_lt('ghc', '7.1', expect_fail), compile, [''])
test('T1769', when(compiler_lt('ghc', '7.1'), expect_fail), compile, [''])
test('T4497', normal, compile, [''])
test('T3484', normal, compile, [''])
test('T3460', normal, compile, [''])
......
......@@ -65,7 +65,7 @@ test('T2239', normal, compile_fail, [''])
test('T3440', normal, compile_fail, [''])
test('T4485', normal, compile_fail, [''])
test('T4174', normal, compile_fail, [''])
test('DerivUnsatFam', if_compiler_lt('ghc', '7.1', expect_fail), compile_fail, [''])
test('DerivUnsatFam', when(compiler_lt('ghc', '7.1'), expect_fail), compile_fail, [''])
test('T2664', normal, compile_fail, [''])
test('T2664a', normal, compile, [''])
test('T2544', normal, compile_fail, [''])
......
......@@ -39,7 +39,7 @@ test('layout007',
[req_interp,
extra_clean(['layout007.hi', 'layout007.o']),
only_compiler_types(['ghc']),
if_compiler_profiled(skip)],
when(compiler_profiled(), skip)],
run_command,
['$MAKE -s --no-print-directory layout007'])
......
......@@ -251,7 +251,7 @@ test('mod150', normal, compile_fail, [''])
test('mod151', normal, compile_fail, [''])
test('mod152', normal, compile_fail, [''])
test('mod153', normal, compile_fail, [''])
test('mod154', if_compiler_type('hugs', expect_fail), compile, [''])
test('mod154', when(compiler_type('hugs'), expect_fail), compile, [''])
test('mod155', normal, compile_fail, [''])
test('mod156', normal, compile, [''])
test('mod157',
......
setTestOpts(only_compiler_types(['ghc']))
test('base01',
[if_compiler_lt('ghc', '7.1', expect_fail),
[when(compiler_lt('ghc', '7.1'), expect_fail),
normalise_slashes,
clean_cmd('$MAKE -s clean')],
run_command,
......
......@@ -45,8 +45,8 @@ test('read029', normal, compile, [''])
test('read030', normal, compile, [''])
test('read031', normal, compile, [''])
test('read032', normal, compile, [''])
test('read033', if_compiler_type('hugs', expect_fail), compile, [''])
test('read034', if_compiler_type('hugs', expect_fail), compile, [''])
test('read033', when(compiler_type('hugs'), expect_fail), compile, [''])
test('read034', when(compiler_type('hugs'), expect_fail), compile, [''])
test('read036', normal, compile, [''])
test('read037', normal, compile, [''])
test('read038', normal, compile, [''])
......@@ -90,7 +90,7 @@ test('NondecreasingIndentation', normal, compile, [''])
test('mc15', normal, compile, [''])
test('mc16', normal, compile, [''])
test('EmptyDecls', normal, compile, [''])
test('ParserLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile, [''])
test('ParserLambdaCase', when(compiler_lt('ghc', '7.5'), skip), compile, [''])
test('T5243', extra_clean(['T5243A.hi', 'T5243A.o']),
multimod_compile, ['T5243',''])
......
......@@ -23,7 +23,7 @@ test('readFail020', normal, compile_fail, [''])
# empty file (length zero) is not a legal Haskell module. It fails to compile
# because it doesn't contain a definition of Main.main. GHC 5.02 crashed
# on this example.
test('readFail021', if_compiler_type('hugs', expect_fail), compile_fail, [''])
test('readFail021', when(compiler_type('hugs'), expect_fail), compile_fail, [''])
test('readFail022', normal, compile_fail, [''])
test('readFail023', normal, compile_fail, [''])
......@@ -72,8 +72,8 @@ test('NondecreasingIndentationFail', normal, compile_fail, [''])
test('readFailTraditionalRecords1', normal, compile_fail, [''])
test('readFailTraditionalRecords2', normal, compile_fail, [''])
test('readFailTraditionalRecords3', normal, compile_fail, [''])
test('ParserNoLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
test('ParserNoMultiWayIf', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
test('ParserNoLambdaCase', when(compiler_lt('ghc', '7.5'), skip), compile_fail, [''])
test('ParserNoMultiWayIf', when(compiler_lt('ghc', '7.5'), skip), compile_fail, [''])
test('T5425', normal, compile_fail, [''])
test('T984', normal, compile_fail, [''])
......@@ -5,4 +5,4 @@ test('readRun004', normal, compile_and_run, ['-fobject-code'])
test('T1344', normal, compile_and_run, [''])
test('operator', normal, compile_and_run, [''])
test('operator2', normal, compile_and_run, [''])
test('ParserMultiWayIf', if_compiler_lt('ghc', '7.5', skip), compile_and_run, [''])
test('ParserMultiWayIf', when(compiler_lt('ghc', '7.5'), skip), compile_and_run, [''])
test('haddock.base',
[unless_in_tree_compiler(skip)
[unless(in_tree_compiler(), skip)
,stats_num_field('peak_megabytes_allocated',
[(wordsize(64), 274, 10)
# 2012-08-14: 240 (amd64/Linux)
......@@ -41,7 +41,7 @@ test('haddock.base',
['../../../../libraries/base/dist-install/doc/html/base/base.haddock.t'])
test('haddock.Cabal',
[unless_in_tree_compiler(skip)
[unless(in_tree_compiler(), skip)
,stats_num_field('peak_megabytes_allocated',
[(wordsize(64), 217, 10)
# 2012-08-14: 202 (amd64/Linux)
......@@ -80,7 +80,7 @@ test('haddock.Cabal',
['../../../../libraries/Cabal/Cabal/dist-install/doc/html/Cabal/Cabal.haddock.t'])
test('haddock.compiler',
[unless_in_tree_compiler(skip)
[unless(in_tree_compiler(), skip)
,stats_num_field('peak_megabytes_allocated',
[(wordsize(64), 1240, 10)
# 2012-08-14: 1203 (amd64/Linux)
......
......@@ -3,7 +3,7 @@ def f(name, opts):
opts.skip = 1
setTestOpts(f)
setTestOpts(if_compiler_lt('ghc', '7.1', skip))
setTestOpts(when(compiler_lt('ghc', '7.1'), skip))
test('plugins01',
[pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins01'),
......
......@@ -2,7 +2,7 @@
test('life_space_leak',
[skip_if_fast,
extra_clean(['Main.hi', 'Main.o']),
if_compiler_type('hugs', expect_fail)],
when(compiler_type('hugs'), expect_fail)],
multimod_compile_and_run,
['Main', ''])
......@@ -161,7 +161,7 @@ test('T4240',
['$MAKE -s --no-print-directory T4240'])
test('T4489', normal, compile, [''])
test('T4478', if_compiler_lt('ghc', '7.1', expect_fail), compile, [''])
test('T4478', when(compiler_lt('ghc', '7.1'), expect_fail), compile, [''])
test('T4534', normal, compile, [''])
test('mc09', normal, compile, [''])
......
......@@ -51,7 +51,7 @@ test('T2783', [ omit_ways(['ghci']), exit_code(1) ], compile_and_run, [''])
# Test the work-stealing deque implementation. We run this test in
# both threaded1 (-threaded -debug) and threaded2 (-threaded) ways.
test('testwsdeque', [unless_in_tree_compiler(skip),
test('testwsdeque', [unless(in_tree_compiler(), skip),
c_src, only_ways(['threaded1', 'threaded2'])],
compile_and_run, ['-I../../../rts'])
......
......@@ -64,7 +64,7 @@ test('T4908', only_ways(['optasm']),
compile,
['-O2 -ddump-simpl -dsuppress-uniques'])
test('T4930', [if_compiler_lt('ghc', '7.1', expect_fail),
test('T4930', [when(compiler_lt('ghc', '7.1'), expect_fail),
only_ways(['optasm'])],
compile,
['-O -ddump-simpl -dsuppress-uniques'])
......@@ -109,7 +109,7 @@ test('T4918',
['$MAKE -s --no-print-directory T4918'])
test('T4945',
if_compiler_lt('ghc', '7.1', expect_fail),
when(compiler_lt('ghc', '7.1'), expect_fail),
run_command,
['$MAKE -s --no-print-directory T4945'])
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('T2014',
[req_interp,
......
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('TH_import_loop',
[extra_clean(['ModuleA.o-boot', 'ModuleA.hi-boot',
......
......@@ -6,7 +6,7 @@ def f(name, opts):
setTestOpts(f)
setTestOpts(only_compiler_types(['ghc']))
setTestOpts(only_ways(['normal','ghci']))
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('TH_spliceViewPat',
extra_clean(['Main.o', 'Main.hi', 'A.o', 'A.hi']),
......
# This test needs to come before the setTestOpts calls below, as we want
# to run it !if_compiler_profiled
test('T4255', unless_compiler_profiled(skip), compile_fail, ['-v0'])
# to run it if !compiler_profiled
test('T4255', unless(compiler_profiled(), skip), compile_fail, ['-v0'])
def f(name, opts):
opts.extra_hc_opts = '-XTemplateHaskell -package template-haskell'
......@@ -11,7 +11,7 @@ def f(name, opts):
setTestOpts(f)
setTestOpts(only_compiler_types(['ghc']))
setTestOpts(only_ways(['normal','ghci']))
setTestOpts(if_compiler_profiled(skip))
setTestOpts(when(compiler_profiled(), skip))
test('TH_mkName', normal, compile, ['-v0'])
test('TH_1tuple', normal, compile_fail, ['-v0'])
......
......@@ -84,7 +84,7 @@ test('tc079', normal, compile, [''])
test('tc080', normal, compile, [''])
test('tc081', normal, compile, [''])
test('tc082', normal, compile, [''])
test('tc084', if_compiler_type('hugs', expect_fail), compile, [''])
test('tc084', when(compiler_type('hugs'), expect_fail), compile, [''])
test('tc085', only_compiler_types(['ghc']), compile, [''])
test('tc086', normal, compile, [''])
test('tc087', normal, compile, [''])
......@@ -96,7 +96,7 @@ test('tc092', normal, compile, [''])
test('tc093', normal, compile, [''])
test('tc094', normal, compile, [''])
test('tc095', normal, compile, [''])
test('tc096', if_compiler_type('hugs', expect_fail), compile, [''])
test('tc096', when(compiler_type('hugs'), expect_fail), compile, [''])
test('tc097', normal, compile, [''])
test('tc098', normal, compile, [''])
test('tc099', normal, compile, [''])
......@@ -380,7 +380,7 @@ test('T6055', normal, compile, [''])
test('DfltProb1', normal, compile, [''])
test('DfltProb2', normal, compile, [''])
test('T6134', normal, compile, [''])
test('TcLambdaCase', if_compiler_lt('ghc', '7.5', skip), compile, [''])
test('TcLambdaCase', when(compiler_lt('ghc', '7.5'), skip), compile, [''])
test('T7147', normal, compile, [''])
test('T7171',normal,run_command,
['$MAKE -s --no-print-directory T7171'])
......
......@@ -24,7 +24,7 @@ test('tcfail023', normal, compile_fail, [''])
test('tcfail027', normal, compile_fail, [''])
test('tcfail028', normal, compile_fail, [''])
test('tcfail029', normal, compile_fail, [''])
test('tcfail030', if_compiler_type('hugs', expect_fail), compile_fail, [''])
test('tcfail030', when(compiler_type('hugs'), expect_fail), compile_fail, [''])
test('tcfail031', normal, compile_fail, [''])
test('tcfail032', normal, compile_fail, [''])
test('tcfail033', normal, compile_fail, [''])
......@@ -278,7 +278,7 @@ test('FDsFromGivens', normal, compile_fail, [''])
test('T7019', normal, compile_fail,[''])
test('T7019a', normal, compile_fail,[''])
test('T5978', normal, compile_fail, [''])
test('TcMultiWayIfFail', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
test('TcMultiWayIfFail', when(compiler_lt('ghc', '7.5'), skip), compile_fail, [''])
test('T2534', normal, compile_fail, [''])
test('T7175', normal, compile_fail, [''])
test('T7210', normal, compile_fail, [''])
......
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