summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-07-23 11:31:47 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-26 13:23:59 -0400
commite91672f0b7185bbafbe8ed1f2ae2cb775111f950 (patch)
treee0b7f2265b3e1ffd6bb3fd824eccb69c65b7d276
parentf153a1d0a3351ad4d94cef4cef8e63bab5b47008 (diff)
downloadhaskell-e91672f0b7185bbafbe8ed1f2ae2cb775111f950.tar.gz
testsuite: Normalise WinIO error message differences
Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors.
-rw-r--r--libraries/base/tests/IO/all.T6
-rw-r--r--testsuite/driver/testlib.py24
2 files changed, 27 insertions, 3 deletions
diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T
index f03f6a01f1..c828975584 100644
--- a/libraries/base/tests/IO/all.T
+++ b/libraries/base/tests/IO/all.T
@@ -10,7 +10,7 @@ test('IOError001', [omit_ways(['ghci']), set_stdin('IOError001.hs')],
test('IOError002', normal, compile_and_run, [''])
test('finalization001', normal, compile_and_run, [''])
test('hClose001', [], compile_and_run, [''])
-test('hClose002', [], compile_and_run, [''])
+test('hClose002', [normalise_win32_io_errors], compile_and_run, [''])
test('hClose003', reqlib('unix'), compile_and_run, ['-package unix'])
test('hFileSize001', normal, compile_and_run, [''])
test('hFileSize002', [omit_ways(['ghci'])], compile_and_run, [''])
@@ -61,8 +61,8 @@ test('misc001', [extra_run_opts('misc001.hs misc001.out')], compile_and_run,
[''])
test('openFile001', normal, compile_and_run, [''])
-test('openFile002', exit_code(1), compile_and_run, [''])
-test('openFile003', [], compile_and_run, [''])
+test('openFile002', [exit_code(1), normalise_win32_io_errors], compile_and_run, [''])
+test('openFile003', [normalise_win32_io_errors], compile_and_run, [''])
test('openFile004', [], compile_and_run, [''])
test('openFile005', [], compile_and_run, [''])
test('openFile006', [], compile_and_run, [''])
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index a6ff229c06..fc83eb6477 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -743,6 +743,30 @@ def normalise_whitespace_fun(f):
def _normalise_whitespace_fun(name, opts, f):
opts.whitespace_normaliser = f
+def normalise_win32_io_errors(name, opts):
+ """
+ On Windows we currently have two IO manager implementations: both WinIO IO
+ manager and the old POSIX-emulated implementation. These currently differ
+ slightly in the error messages that they provide. Normalise these
+ differences away, preferring the new WinIO errors.
+
+ This can be dropped when the old IO manager is removed.
+ """
+
+ SUBS = [
+ ('Bad file descriptor', 'The handle is invalid'),
+ ('Permission denied', 'Access is denied.'),
+ ('No such file or directory', 'The system cannot find the file specified.'),
+ ]
+
+ def f(s: str):
+ for old,new in SUBS:
+ s = s.replace(old, new)
+
+ return s
+
+ return when(opsys('mingw32'), normalise_fun(f))
+
def normalise_version_( *pkgs ):
def normalise_version__( str ):
return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+',