From b519ddf9e8cd30fba3a7a210b3493e11f64effc8 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Tue, 14 Nov 2023 11:52:11 +0000 Subject: [PATCH] testsuite: Improve error message in findDependencyInStore --- cabal-testsuite/src/Test/Cabal/Prelude.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index e0e63ac18f6..6a9b3b84953 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -1156,5 +1156,7 @@ findDependencyInStore storeDir pkgName = do then filter (not . flip elem "aeiou") pkgName -- simulates the way 'hashedInstalledPackageId' uses to compress package name else pkgName - let libDir = head $ filter (pkgName' `isPrefixOf`) packageDirs + let libDir = case filter (pkgName' `isPrefixOf`) packageDirs of + [] -> error $ "Could not find " <> pkgName' <> " when searching for " <> pkgName' <> " in\n" <> show packageDirs + (dir:_) -> dir pure (storeDir storeDirForGhcVersion libDir)