[Git][ghc/ghc][master] testsuite: Handle exceptions in framework_fail when testdir is not initialised

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed May 1 02:45:52 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
c56d728e by Zubin Duggal at 2024-04-30T22:45:09-04:00
testsuite: Handle exceptions in framework_fail when testdir is not initialised

When `framework_fail` is called before initialising testdir, it would fail with
an exception reporting the testdir not being initialised instead of the actual failure.

Ensure we report the actual reason for the failure instead of failing in this way.

One way this can manifest is when trying to run a test that doesn't exist using `--only`

- - - - -


1 changed file:

- testsuite/driver/testlib.py


Changes:

=====================================
testsuite/driver/testlib.py
=====================================
@@ -1542,7 +1542,13 @@ def override_options(pre_cmd):
 
 def framework_fail(name: Optional[TestName], way: Optional[WayName], reason: str) -> None:
     opts = getTestOpts()
-    directory = re.sub(r'^\.[/\\]', '', str(opts.testdir))
+    # framework_fail can be called before testdir is initialised,
+    # so we need to take care not to blow up with the wrong way
+    # and report the actual reason for the failure.
+    try:
+      directory = re.sub(r'^\.[/\\]', '', str(opts.testdir))
+    except:
+      directory = ''
     full_name = '%s(%s)' % (name, way)
     if_verbose(1, '*** framework failure for %s %s ' % (full_name, reason))
     name2 = name if name is not None else TestName('none')



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56d728e1f8702db02cf7e7e3cdc567b3df47ac3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56d728e1f8702db02cf7e7e3cdc567b3df47ac3
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/20240430/6bf9ca72/attachment-0001.html>


More information about the ghc-commits mailing list