Commit 8f4ee52c authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add if_platform and remove *_if_platform

This removes some duplication from the testsuite driver
parent e5d157f9
......@@ -183,22 +183,6 @@ def _only_compiler_types( opts, compiler_types ):
# -----
def expect_fail_if_platform( plat ):
return lambda opts, p=plat: _expect_fail_if_platform(opts, p)
def _expect_fail_if_platform( opts, plat ):
if config.platform == plat:
opts.expect = 'fail'
def expect_broken_if_platform( bug, plat ):
return lambda opts, b=bug, p=plat: _expect_broken_if_platform(opts, b, p)
def _expect_broken_if_platform( opts, bug, plat ):
if config.platform == plat:
opts.expect = 'fail'
# -----
def expect_fail_if_compiler_type( compiler_type ):
return lambda opts, c=compiler_type: _expect_fail_if_compiler_type(opts, c)
......@@ -229,13 +213,6 @@ def exit_code( val ):
def _exit_code( opts, v ):
opts.exit_code = v
def exit_code_if_platform( val, plat ):
return lambda opts, v=val, p=plat: _exit_code_if_platform(opts, v, p)
def _exit_code_if_platform( opts, val, plat ):
if config.platform == plat:
opts.exit_code = val
# -----
def extra_run_opts( val ):
......@@ -269,12 +246,11 @@ def skip_if_fast(opts):
# -----
def skip_if_platform( plat ):
return lambda opts, p=plat: _skip_if_platform(opts, p)
def _skip_if_platform( opts, plat ):
def if_platform( plat, f ):
if config.platform == plat:
opts.skip = 1
return f
else:
return normal
# ---
......
# cabal-setup isn't in the GHC tree any more; this test should probably
# be moved to the cabal-setup package.
test('cabal02', compose(skip, compose(compose(ignore_output, skip_if_fast), expect_broken_if_platform(1196, 'i386-unknown-mingw32'))), run_command, ['$MAKE cabal02'])
test('cabal02', compose(skip, compose(compose(ignore_output, skip_if_fast), if_platform('i386-unknown-mingw32', expect_broken(1196)))), run_command, ['$MAKE cabal02'])
......@@ -33,7 +33,7 @@ test('ghci022', normal, ghci_script, ['ghci022.script'])
test('ghci023', normal, ghci_script, ['ghci023.script'])
execfile(in_testdir('ghci024.py')) # load function prepare024
test('ghci024', compose(prepare024,expect_broken_if_platform(1845,"powerpc_apple_darwin")), ghci_script, ['ghci024.script'])
test('ghci024', compose(prepare024, if_platform("powerpc_apple_darwin", expect_broken(1845))), ghci_script, ['ghci024.script'])
test('ghci025', normal, ghci_script, ['ghci025.script'])
test('ghci026', normal, ghci_script, ['ghci026.script'])
......
def expect_fail_if_windows(opts):
f = expect_fail_if_platform('i386-unknown-mingw32');
f = if_platform('i386-unknown-mingw32', expect_fail);
return f(opts);
test('IOError001', compose(omit_ways(['ghci']), set_stdin('IOError001.hs')),
......@@ -82,7 +82,7 @@ clean(['readwrite001.inout'])
test('readwrite002',
composes([omit_ways(['ghci']),
set_stdin('readwrite002.hs'),
skip_if_platform('i386-unknown-mingw32') # see #1198
if_platform('i386-unknown-mingw32', skip) # see #1198
]),
compile_and_run, ['-cpp'])
clean(['readwrite002.inout'])
......
test('echo001', set_stdin("echo001.hs"), compile_and_run, [''])
test('hTell001', expect_fail_if_platform("i386-unknown-mingw32"), \
test('hTell001', if_platform("i386-unknown-mingw32", expect_fail), \
compile_and_run, [''])
test('hTell002', expect_fail_if_platform("i386-unknown-mingw32"), \
test('hTell002', if_platform("i386-unknown-mingw32", expect_fail), \
compile_and_run, [''])
test('performGC001', normal, compile_and_run, [''])
......
......@@ -3,6 +3,6 @@ test('exitWith001', exit_code(42), compile_and_run, [''])
test('getArgs001', normal, compile_and_run, [''])
test('getEnv001', normal, compile_and_run, [''])
test('system001', expect_fail_if_platform("i386-unknown-mingw32"), \
test('system001', if_platform("i386-unknown-mingw32", expect_fail), \
compile_and_run, [''])
......@@ -11,14 +11,14 @@ test('derefnull',
# SIGSEGV on Linux
composes([exit_code(139),
# SIGBUS on OX X
exit_code_if_platform(138, 'i386-apple-darwin'),
exit_code_if_platform(138, 'powerpc-apple-darwin'),
exit_code_if_platform(1, 'i386-unknown-mingw32')]),
if_platform('i386-apple-darwin', exit_code(138)),
if_platform('powerpc-apple-darwin', exit_code(138)),
if_platform('i386-unknown-mingw32', exit_code(1))]),
compile_and_run, [''])
test('divbyzero',
# SIGFPE on Linux
compose(exit_code(136),
exit_code_if_platform(1, 'i386-unknown-mingw32')),
if_platform('i386-unknown-mingw32', exit_code(1))),
compile_and_run, [''])
test('outofmem', normal, run_command, ['$MAKE -s --no-print-directory outofmem'])
......
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