[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Remove `extra_src_files` variable from `testsuite/driver/testlib.py`
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1c79a4cd by Michael Alan Dorman at 2026-02-09T08:11:51-05:00 Remove `extra_src_files` variable from `testsuite/driver/testlib.py` While reading through the test harness code, I noticed this variable with a TODO attached that referenced #12223. Although that bug is closed, it strongly implied that this special-case variable that only affected a single test was expected to be removed at some point. I also looked at 3415bcaa0b1903b5e12dfaadb5b774718e406eab---where it was added---whose commit message suggested that it would have been desirable to remove it, but that there were special circumstances that meant it had to remain (though it doesn't elucidate what those special circumstances are). However, the special circumstances were mentioned as if the test was in a different location than is currently is, so I decided to try changing the test to use the standard `extra_files` mechanism, which works in local testing. This also seems like a reasonable time to remove the script that was originally used in the transition, since it doesn't really serve a purpose anymore. - - - - - 30864804 by Matthew Pickering at 2026-02-09T12:48:52-05:00 determinism: Use a stable sort in WithHsDocIdentifiers binary instance `WithHsDocIdentifiers` is defined as ``` 71 data WithHsDocIdentifiers a pass = WithHsDocIdentifiers 72 { hsDocString :: !a 73 , hsDocIdentifiers :: ![Located (IdP pass)] 74 } ``` This list of names is populated from `rnHsDocIdentifiers`, which calls `lookupGRE`, which calls `lookupOccEnv_AllNameSpaces`, which calls `nonDetEltsUFM` and returns the results in an order depending on uniques. Sorting the list with a stable sort before returning the interface makes the output deterministic and follows the approach taken by other fields in `Docs`. Fixes #26858 - - - - - 87512d2e by echoumcp1 at 2026-02-09T12:48:55-05:00 Replace putstrln with logMsg in handleSeqHValueStatus Fixes #26549 - - - - - 9 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Runtime/Interpreter.hs - − testsuite/driver/kill_extra_files.py - testsuite/driver/testlib.py - testsuite/tests/process/all.T - testsuite/tests/showIface/DocsInHiFile1.stdout - testsuite/tests/showIface/HaddockSpanIssueT24378.stdout - testsuite/tests/showIface/MagicHashInHaddocks.stdout Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -45,6 +45,7 @@ import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map import Data.List (sortBy) +import Data.Function import GHC.Hs.DocString @@ -83,7 +84,7 @@ instance Outputable a => Outputable (WithHsDocIdentifiers a pass) where instance Binary a => Binary (WithHsDocIdentifiers a GhcRn) where put_ bh (WithHsDocIdentifiers s ids) = do put_ bh s - put_ bh $ BinLocated <$> ids + put_ bh $ BinLocated <$> (sortBy (stableNameCmp `on` getName) ids) get bh = liftA2 WithHsDocIdentifiers (get bh) (fmap unBinLocated <$> get bh) ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -788,6 +788,7 @@ cvObtainTerm hsc_env max_depth force old_ty hval = runTR hsc_env $ do where interp = hscInterp hsc_env unit_env = hsc_unit_env hsc_env + logger = hsc_logger hsc_env go :: Int -> Type -> Type -> ForeignHValue -> TcM Term -- [SPJ May 11] I don't understand the difference between my_ty and old_ty @@ -812,7 +813,7 @@ cvObtainTerm hsc_env max_depth force old_ty hval = runTR hsc_env $ do -- Thunks we may want to force t | isThunk t && force -> do traceTR (text "Forcing a " <> text (show (fmap (const ()) t))) - evalRslt <- liftIO $ GHCi.seqHValue interp unit_env a + evalRslt <- liftIO $ GHCi.seqHValue interp unit_env logger a case evalRslt of -- #2950 EvalSuccess _ -> go (pred max_depth) my_ty old_ty a EvalException ex -> do ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -85,11 +85,13 @@ import GHC.Data.FastString import GHC.Types.SrcLoc import GHC.Types.Basic +import GHC.Types.Error import GHC.Utils.Panic import GHC.Utils.Exception as Ex -import GHC.Utils.Outputable(brackets, ppr, showSDocUnsafe) +import GHC.Utils.Outputable import GHC.Utils.Fingerprint +import GHC.Utils.Logger (Logger, logMsg) import GHC.Unit.Module import GHC.Unit.Home.ModInfo @@ -401,11 +403,11 @@ whereFrom interp ref = interpCmd interp (WhereFrom hval) -- | Send a Seq message to the iserv process to force a value #2950 -seqHValue :: Interp -> UnitEnv -> ForeignHValue -> IO (EvalResult ()) -seqHValue interp unit_env ref = +seqHValue :: Interp -> UnitEnv -> Logger -> ForeignHValue -> IO (EvalResult ()) +seqHValue interp unit_env logger ref = withForeignRef ref $ \hval -> do status <- interpCmd interp (Seq hval) - handleSeqHValueStatus interp unit_env status + handleSeqHValueStatus interp unit_env logger status evalBreakpointToId :: EvalBreakpoint -> InternalBreakpointId evalBreakpointToId eval_break = @@ -419,16 +421,15 @@ evalBreakpointToId eval_break = } -- | Process the result of a Seq or ResumeSeq message. #2950 -handleSeqHValueStatus :: Interp -> UnitEnv -> EvalStatus () -> IO (EvalResult ()) -handleSeqHValueStatus interp unit_env eval_status = +handleSeqHValueStatus :: Interp -> UnitEnv -> Logger -> EvalStatus () -> IO (EvalResult ()) +handleSeqHValueStatus interp unit_env logger eval_status = case eval_status of (EvalBreak _ maybe_break resume_ctxt _) -> do -- A breakpoint was hit; inform the user and tell them -- which breakpoint was hit. resume_ctxt_fhv <- liftIO $ mkFinalizedHValue interp resume_ctxt - - let put x = putStrLn ("*** Ignoring breakpoint " ++ (showSDocUnsafe x)) - let nothing_case = put $ brackets . ppr $ mkGeneralSrcSpan (fsLit "<unknown>") + let put loc = logMsg logger MCOutput loc ("*** Ignoring breakpoint" <+> brackets (ppr loc)) + let nothing_case = put noSrcSpan case maybe_break of Nothing -> nothing_case -- Nothing case - should not occur! @@ -445,13 +446,12 @@ handleSeqHValueStatus interp unit_env eval_status = -- Nothing case - should not occur! We should have the appropriate -- breakpoint information Nothing -> nothing_case - Just modbreaks -> put . brackets . ppr =<< - getBreakLoc (readIModModBreaks hug) ibi modbreaks + Just modbreaks -> put =<< getBreakLoc (readIModModBreaks hug) ibi modbreaks -- resume the seq (:force) processing in the iserv process withForeignRef resume_ctxt_fhv $ \hval -> do status <- interpCmd interp (ResumeSeq hval) - handleSeqHValueStatus interp unit_env status + handleSeqHValueStatus interp unit_env logger status (EvalComplete _ r) -> return r ===================================== testsuite/driver/kill_extra_files.py deleted ===================================== @@ -1,101 +0,0 @@ -#!/usr/bin/env python3 -from typing import Dict, List, Set, NamedTuple - -import os -import subprocess -import ast - -import extra_files -extra_src_files = extra_files.extra_src_files # type: Dict[str, List[str]] - -found_tests = set() # type: Set[str] -fixed_tests = set() # type: Set[str] - -def extras(name: str) -> str: - return 'extra_files(%s)' % (extra_src_files[name],) - -def list_extras(name: str, col: int) -> str: - return extras(name) + ',\n' + ' ' * (col + 1) - -def find_all_T_files(basedir: bytes) -> List[bytes]: - result = [] # type: List[bytes] - for dirpath, dirnames, filenames in os.walk(basedir): - for f in filenames: - if f.endswith(b'.T'): - result.append(os.path.join(dirpath, f)) - return result - -# Delete del bytes from (line, col) and then insert the string ins there. -Fixup = NamedTuple('Fixup', [('line', int), - ('col', int), - ('delete', int), - ('insert', str)]) - -class TestVisitor(ast.NodeVisitor): - def __init__(self) -> None: - self.fixups = [] # type: List[Fixup] - - def visit_Call(self, node: ast.AST) -> None: - self.generic_visit(node) - assert isinstance(node, ast.Call) - - if isinstance(node.func, ast.Name) and node.func.id == 'test': - assert(len(node.args) == 4) - name_expr, setup, test_fn, args = node.args - if not(isinstance(name_expr, ast.Str)): - return - name = name_expr.s - if name in extra_src_files: - found_tests.add(name) - if isinstance(setup, ast.Name): - if setup.id == 'normal': - # Kill it - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset, - delete=len(setup.id), insert=extras(name))) - else: - # Make a lit - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset, - delete=0, - insert='[' + list_extras(name, setup.col_offset))) - self.fixups.append(Fixup( - line=setup.lineno, - col=setup.col_offset + len(setup.id), - delete=0, insert=']')) - fixed_tests.add(name) - elif isinstance(setup, ast.List): - # Insert into list at start - if not setup.elts: - ins = extras(name) # no need for comma, newline - # Don't try to delete the list because someone - # might have written "[ ]" for some reason - else: - ins = list_extras(name, setup.col_offset) - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset + 1, - delete=0, insert=ins)) - fixed_tests.add(name) - else: - assert False # we fixed them all manually already - -basedir = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']) -basedir = basedir[0:-1] # delete trailing newline -print(basedir) -for f in find_all_T_files(basedir): - print(f) - text = open(f).read() - mod = ast.parse(text) - tv = TestVisitor() - tv.visit(mod) - - lines = text.split('\n') - if not tv.fixups: - # Don't rewrite files unnecessarily - # (libraries/Win32 has Windows line endings) - continue - for fixup in reversed(tv.fixups): - l = list(lines[fixup.line-1]) - l[fixup.col:fixup.col + fixup.delete] = fixup.insert - lines[fixup.line-1] = ''.join(l) - open(f, 'w').write('\n'.join(lines)) ===================================== testsuite/driver/testlib.py ===================================== @@ -31,7 +31,6 @@ import testutil from cpu_features import have_cpu_feature import perf_notes as Perf from perf_notes import MetricChange, PerfStat, StatsException, AlwaysAccept, RelativeMetricAcceptanceWindow -extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -1644,7 +1643,7 @@ async def test_common_work(name: TestName, opts, if f.startswith(name) and not f == name and not f.endswith(testdir_suffix) and not os.path.splitext(f)[1] in do_not_copy) - for filename in (opts.extra_files + extra_src_files.get(name, [])): + for filename in (opts.extra_files): if filename.startswith('/'): framework_fail(name, None, 'no absolute paths in extra_files please: ' + filename) ===================================== testsuite/tests/process/all.T ===================================== @@ -27,6 +27,7 @@ test('T3231', ['']) test('T4198', [pre_cmd('{compiler} exitminus1.c -no-hs-main -o exitminus1'), + extra_files(['exitminus1.c']), js_broken(22349), req_process], compile_and_run, ===================================== testsuite/tests/showIface/DocsInHiFile1.stdout ===================================== @@ -6,14 +6,14 @@ docs: '<>', ':=:', 'Bool' -} identifiers: + {DocsInHiFile.hs:4:2-3} + GHC.Internal.Base.<> {DocsInHiFile.hs:2:6-9} GHC.Internal.Data.Foldable.elem - {DocsInHiFile.hs:2:6-9} - elem {DocsInHiFile.hs:2:14-18} GHC.Internal.System.IO.print - {DocsInHiFile.hs:4:2-3} - GHC.Internal.Base.<> + {DocsInHiFile.hs:2:6-9} + elem {DocsInHiFile.hs:4:15-18} GHC.Internal.Types.Bool export docs: ===================================== testsuite/tests/showIface/HaddockSpanIssueT24378.stdout ===================================== @@ -6,14 +6,14 @@ docs: '<>', ':=:', 'Bool' -} identifiers: + {HaddockSpanIssueT24378.hs:3:2-3} + GHC.Internal.Base.<> {HaddockSpanIssueT24378.hs:1:6-9} GHC.Internal.Data.Foldable.elem - {HaddockSpanIssueT24378.hs:1:6-9} - elem {HaddockSpanIssueT24378.hs:1:14-18} GHC.Internal.System.IO.print - {HaddockSpanIssueT24378.hs:3:2-3} - GHC.Internal.Base.<> + {HaddockSpanIssueT24378.hs:1:6-9} + elem {HaddockSpanIssueT24378.hs:3:15-18} GHC.Internal.Types.Bool export docs: ===================================== testsuite/tests/showIface/MagicHashInHaddocks.stdout ===================================== @@ -3,10 +3,10 @@ docs: Just text: -- | 'foo#' `Bar##` `*##` identifiers: - {MagicHashInHaddocks.hs:3:7-10} - foo# {MagicHashInHaddocks.hs:3:14-18} Bar## + {MagicHashInHaddocks.hs:3:7-10} + foo# export docs: [] declaration docs: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a1678ea6aa3722b4de008e4ed24150c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a1678ea6aa3722b4de008e4ed24150c... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)