@@ -1927,6 +1927,18 @@ singleTest topts testsToRun ac ee task installedMap = do
19271927 tixPath <- liftM (pkgDir </> ) $ parseRelFile $ exeName ++ " .tix"
19281928 exePath <- liftM (buildDir </> ) $ parseRelFile $ " build/" ++ testName' ++ " /" ++ exeName
19291929 exists <- doesFileExist exePath
1930+ -- in Stack.Package.packageFromPackageDescription we filter out
1931+ -- package itself of any dependencies so any tests requiring loading
1932+ -- of their own package library will fail
1933+ -- so to prevent this we return it back here but unfortunately unconditionally
1934+ installed <- case Map. lookup pname installedMap of
1935+ Just (_, installed) -> pure $ Just installed
1936+ Nothing -> do
1937+ idMap <- liftIO $ readTVarIO (eeGhcPkgIds ee)
1938+ pure $ Map. lookup (taskProvides task) idMap
1939+ let pkgGhcIdList = case installed of
1940+ Just (Library _ ghcPkgId _) -> [ghcPkgId]
1941+ _ -> []
19301942 -- doctest relies on template-haskell in QuickCheck-based tests
19311943 thGhcId <- case find ((== " template-haskell" ) . pkgName . dpPackageIdent. snd )
19321944 (Map. toList $ eeGlobalDumpPkgs ee) of
@@ -1949,7 +1961,7 @@ singleTest topts testsToRun ac ee task installedMap = do
19491961 " package-db " <> fromString snapDBPath <> " \n " <>
19501962 " package-db " <> fromString localDBPath <> " \n " <>
19511963 foldMap (\ ghcId -> " package-id " <> RIO. display (unGhcPkgId ghcId) <> " \n " )
1952- (thGhcId: M. elems allDepsMap)
1964+ (pkgGhcIdList ++ thGhcId: M. elems allDepsMap)
19531965 writeFileUtf8Builder fp ghcEnv
19541966 menv <- liftIO $ setEnv fp =<< configProcessContextSettings config EnvSettings
19551967 { esIncludeLocals = taskLocation task == Local
0 commit comments