From 42375731a75a0fbfafcf0cdd77afceadcc452bdb Mon Sep 17 00:00:00 2001
From: Mikhail Glushenkov <mikhail.glushenkov@gmail.com>
Date: Tue, 17 Mar 2015 20:19:56 +0100
Subject: [PATCH] Fix the DeterministicAr test on 7.10.

---
 Cabal/Distribution/Package.hs                 |  1 +
 .../PackageTests/DeterministicAr/Check.hs     | 22 +++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Cabal/Distribution/Package.hs b/Cabal/Distribution/Package.hs
index e9b14e2184..f36a4ce8c5 100644
--- a/Cabal/Distribution/Package.hs
+++ b/Cabal/Distribution/Package.hs
@@ -27,6 +27,7 @@ module Distribution.Package (
         -- * Package keys (used for linker symbols and library name)
         PackageKey(..),
         mkPackageKey,
+        packageKeyHash,
         packageKeyLibraryName,
 
         -- * Package source dependencies
diff --git a/Cabal/tests/PackageTests/DeterministicAr/Check.hs b/Cabal/tests/PackageTests/DeterministicAr/Check.hs
index cf5562396d..8f35a56a73 100644
--- a/Cabal/tests/PackageTests/DeterministicAr/Check.hs
+++ b/Cabal/tests/PackageTests/DeterministicAr/Check.hs
@@ -17,6 +17,13 @@ import System.FilePath
 import System.IO
 import Test.HUnit (Assertion, Test (TestCase), assertFailure)
 
+import Distribution.Compiler              (CompilerFlavor(..), CompilerId(..))
+import Distribution.Package               (packageKeyHash)
+import Distribution.Version               (Version(..))
+import Distribution.Simple.Compiler       (compilerId)
+import Distribution.Simple.Configure      (getPersistBuildConfig)
+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, compiler, pkgKey)
+
 -- Perhaps these should live in PackageTester.
 
 -- For a polymorphic @IO a@ rather than @Assertion = IO ()@.
@@ -66,15 +73,22 @@ suite ghcPath ghcPkgPath = TestCase $ do
 
     let distBuild = dir </> "dist" </> "build"
     libdir <- ghcPkg_field1 this "library-dirs" ghcPkgPath
-    mapM_ checkMetadata [distBuild, libdir]
+    lbi    <- getPersistBuildConfig (dir </> "dist")
+    mapM_ (checkMetadata lbi) [distBuild, libdir]
     unregister this ghcPkgPath
 
 -- Almost a copypasta of Distribution.Simple.Program.Ar.wipeMetadata
-checkMetadata :: FilePath -> Assertion
-checkMetadata dir = withBinaryFile path ReadMode $ \ h -> do
+checkMetadata :: LocalBuildInfo -> FilePath -> Assertion
+checkMetadata lbi dir = withBinaryFile path ReadMode $ \ h -> do
     hFileSize h >>= checkArchive h
   where
-    path = dir </> "libHS" ++ this ++ "-0.a"
+    path = dir </> "libHS" ++ this ++ "-0"
+           ++ (if ghc_7_10 then ("-" ++ packageKeyHash (pkgKey lbi)) else "")
+           ++ ".a"
+
+    ghc_7_10 = case compilerId (compiler lbi) of
+      CompilerId GHC version | version >= Version [7, 10] [] -> True
+      _                                                      -> False
 
     checkError msg = assertFailure' $
         "PackageTests.DeterministicAr.checkMetadata: " ++ msg ++
-- 
GitLab