From e78c7ef96e395f1ef41f04790aebecd0409b92b9 Mon Sep 17 00:00:00 2001
From: Zubin Duggal <zubin.duggal@gmail.com>
Date: Mon, 14 Oct 2024 14:07:13 +0530
Subject: [PATCH] haddock: oneshot tests can drop files if they share modtimes.
 Stop this by including the filename in the key.

Ideally we would use `ghc -M` output to do a proper toposort

Partially addresses #25372
---
 utils/haddock/haddock-test/src/Test/Haddock.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/haddock/haddock-test/src/Test/Haddock.hs b/utils/haddock/haddock-test/src/Test/Haddock.hs
index 5745955bd6d..151005cd9fd 100644
--- a/utils/haddock/haddock-test/src/Test/Haddock.hs
+++ b/utils/haddock/haddock-test/src/Test/Haddock.hs
@@ -156,7 +156,7 @@ runHaddock cfg@(Config{..}) = do
 
       files <- filter ((== ".hi") . takeExtension) <$> listDirectory hiDir
       -- Use the output order of GHC as a simple dependency order
-      filesSorted <- Map.elems . Map.fromList <$> traverse (\file -> (,file) <$> getModificationTime (hiDir </> file)) files
+      filesSorted <- Map.elems . Map.fromList <$> traverse (\file -> (\mt -> ((mt,file),file)) <$> getModificationTime (hiDir </> file)) files
       let srcRef = if "--hyperlinked-source" `elem` cfgHaddockArgs then ",src,visible," else ""
           loop [] = pure True
           loop (file : files) = do
-- 
GitLab