diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-11-16 10:08:39 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-11-17 09:46:00 -0500 |
commit | 29df661737ffa0c8efa619adea8ea81003382be9 (patch) | |
tree | c6ea4d165313657fbedbb214a89b366ad92ea878 /testsuite/driver/testutil.py | |
parent | b88445d3070d492baf770d8cf6b64038ce65eec3 (diff) | |
download | haskell-wip/fix-windows-again.tar.gz |
testsuite: Work around #17483wip/fix-windows-again
msys2 Python's wrapper for stat (called by Path.exists()) appears to
fail randomly with errno=0. Work around this by retrying 10 times in the
event that this happens.
Diffstat (limited to 'testsuite/driver/testutil.py')
-rw-r--r-- | testsuite/driver/testutil.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py index 071b641b7f..5509acff73 100644 --- a/testsuite/driver/testutil.py +++ b/testsuite/driver/testutil.py @@ -2,12 +2,29 @@ import os import platform import subprocess import shutil -from pathlib import Path, PurePath +from pathlib import PurePath, Path import threading from my_typing import * +# Workaround for #17483. msys2 Python's wrapper for stat (called by +# Path.exists()) appears to fail randomly with errno=0. Work around this by +# retrying 10 times in the event that this happens. +if os.name == 'nt': + # Oh the horror... + def new_stat(self): + for i in range(10): + try: + result = new_stat.stat(self) + return result + except OSError as e: + if e.errno != 0: + raise e + + new_stat.stat = Path.stat # type: ignore + Path.stat = new_stat # type: ignore + PassFail = NamedTuple('PassFail', [('passFail', str), ('reason', str), |