[Git][ghc/ghc][master] testsuite: don't initialize testdir to '.'
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Nov 28 13:01:25 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00
testsuite: don't initialize testdir to '.'
The test directory is removed during cleanup, if there's an interrupt
that could remove the entire repository.
Fixes #24219
- - - - -
2 changed files:
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
Changes:
=====================================
testsuite/driver/testglobals.py
=====================================
@@ -436,8 +436,10 @@ class TestOptions:
# Keep profiling callstacks.
self.keep_prof_callstacks = False
- # The directory the test is in
- self.testdir = Path('.')
+ # The directory the test is run.
+ # Usually you should check the self.testdir property instead,
+ # which crashes when this is not initialised.
+ self.testdir_raw = None # type: Optional[Path]
# Should we redirect stdout and stderr to a single file?
self.combined_output = False
@@ -462,6 +464,12 @@ class TestOptions:
# The extra hadrian dependencies we need for this particular test
self.hadrian_deps = set(["test:ghc"]) # type: Set[str]
+ @property
+ def testdir(self) -> Path:
+ if self.testdir_raw is None:
+ raise Exception('testdir not initialized')
+ return self.testdir_raw
+
# The default set of options
global default_testopts
default_testopts = TestOptions()
=====================================
testsuite/driver/testlib.py
=====================================
@@ -1175,7 +1175,7 @@ testdir_suffix = '.run'
def _newTestDir(name: TestName, opts: TestOptions, tempdir, dir):
testdir = os.path.join('', *(p for p in PurePath(dir).parts if p != '..'))
opts.srcdir = Path.cwd() / dir
- opts.testdir = Path(os.path.join(tempdir, testdir, name + testdir_suffix))
+ opts.testdir_raw = Path(os.path.join(tempdir, testdir, name + testdir_suffix))
opts.compiler_always_flags = config.compiler_always_flags
# -----------------------------------------------------------------------------
@@ -2952,7 +2952,9 @@ def find_expected_file(name: TestName, suff: str) -> Path:
if config.msys:
import stat
def cleanup() -> None:
- testdir = getTestOpts().testdir # type: Path
+ testdir = getTestOpts().testdir_raw # type: Optional[Path]
+ if testdir is None:
+ return
max_attempts = 5
retries = max_attempts
def on_error(function, path: str, excinfo):
@@ -2992,8 +2994,8 @@ if config.msys:
% (testdir, exception))
else:
def cleanup() -> None:
- testdir = getTestOpts().testdir
- if testdir.exists():
+ testdir = getTestOpts().testdir_raw
+ if testdir is not None and testdir.exists():
shutil.rmtree(str(testdir), ignore_errors=False)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e05bca399f02870038e4e5dcecc749c1c1825a44
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e05bca399f02870038e4e5dcecc749c1c1825a44
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231128/eacf66e9/attachment-0001.html>
More information about the ghc-commits
mailing list