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 | |
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.
-rw-r--r-- | testsuite/driver/testglobals.py | 2 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 4 | ||||
-rw-r--r-- | testsuite/driver/testutil.py | 19 |
3 files changed, 22 insertions, 3 deletions
diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index c39ca7a8c9..a2d79391db 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -3,7 +3,7 @@ # from my_typing import * -from pathlib import Path +from testutil import Path from perf_notes import MetricChange, PerfStat, Baseline, MetricOracles from datetime import datetime diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 79d504a845..849996d5f4 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -14,7 +14,8 @@ import copy import glob import sys from math import ceil, trunc -from pathlib import Path, PurePath +from pathlib import PurePath +from testutil import Path import collections import subprocess @@ -39,6 +40,7 @@ if config.use_threads: global wantToStop wantToStop = False + # I have no idea what the type of this is global thisdir_settings thisdir_settings = None # type: ignore 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), |