diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-07-23 11:31:47 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-07-23 14:30:17 -0400 |
commit | 9fe2579076392ca6eb3bb37c6351d2944e3f91c7 (patch) | |
tree | f2f914d5ff60715333383ad63c4dca96849a97da | |
parent | 7b25fb258da259b202652218010b1f95a3ef22f9 (diff) | |
download | haskell-9fe2579076392ca6eb3bb37c6351d2944e3f91c7.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.T | 6 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 24 |
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.]+', |