[Git][ghc/ghc][master] Test driver: normalise line numbers into libraries
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c6d53c16 by sheaf at 2026-07-02T21:35:44-04:00 Test driver: normalise line numbers into libraries When comparing the stdout of tests that print out callstacks, we can't rely on the stability of exact line:column spans pointing into libraries (e.g. ghc-internal), as any change (such as adding a comment) can change them. This commit addresses this by normalising away line:column in callstacks, but only when those point into internal libraries. We don't do this in general, as the exact span might be important to the test (e.g. for a span within the test module itself). Fixes #27387 - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -2944,6 +2944,12 @@ def normalise_whitespace(s: str) -> str: callSite_re = re.compile(r', called at (.+):[\d]+:[\d]+ in [<>\w\-\.]+:') +# A line:column location pointing inside 'libraries' (e.g. ghc-internal). +inLibrariesLoc_re = re.compile( + r'(libraries[\\/]\S+?)' + r':(?:\d+:\d+(?:-\d+)?|\(\d+,\d+\)-\(\d+,\d+\))' # line:col span +) + def normalise_callstacks(s: str) -> str: opts = getTestOpts() def repl(matches): @@ -2952,6 +2958,12 @@ def normalise_callstacks(s: str) -> str: return ', called at {0}:<line>:<column> in <package-id>:'.format(location) # Ignore line number differences in call stacks (#10834). s = re.sub(callSite_re, repl, s) + # Ignore differences in line numbers pointing into internal libraries, + # as those line numbers are not stable (e.g. adding a comment somewhere + # in ghc-internal) (#27387). + s = re.sub(inLibrariesLoc_re, + lambda m: '{0}:<line>:<column>'.format(normalise_slashes_(m.group(1))), + s) # Ignore the change in how we identify implicit call-stacks s = s.replace('from ImplicitParams', 'from HasCallStack') if not opts.keep_prof_callstacks: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6d53c1681d4afe7f6c637c3a34798f0... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6d53c1681d4afe7f6c637c3a34798f0... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)