@@ -263,6 +263,30 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
263263 makeInstall src target =
264264 make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
265265
266+-- -----------------------------------------------------------------------------
267+-- Test
268+
269+-- FIXME: We use the __GLASGOW_HASKELL__ macro because MIN_VERSION_cabal seems
270+-- to be broken !
271+
272+-- There are two "dataDir" in cabal, and they don't relate to each other.
273+-- When fetching modules, idris uses the second path (in the pkg record),
274+-- which by default is the root folder of the project.
275+-- We want it to be the install directory where we put the idris libraries.
276+fixPkg pkg target = pkg { dataDir = target }
277+
278+-- The "Args" argument of the testHooks has been added in cabal 1.22.0,
279+-- and should therefore be ignored for prior versions.
280+#if __GLASGOW_HASKELL__ < 710
281+originalTestHook _ = testHook simpleUserHooks
282+#else
283+originalTestHook = testHook simpleUserHooks
284+#endif
285+
286+idrisTestHook args pkg local hooks flags = do
287+ let target = datadir $ L.absoluteInstallDirs pkg local NoCopyDest
288+ originalTestHook args (fixPkg pkg target) local hooks flags
289+
266290-- -----------------------------------------------------------------------------
267291-- Main
268292
@@ -281,4 +305,9 @@ main = defaultMainWithHooks $ simpleUserHooks
281305 NoCopyDest pkg local
282306 , preSDist = idrisPreSDist
283307 , postSDist = idrisPostSDist
308+#if __GLASGOW_HASKELL__ < 710
309+ , testHook = idrisTestHook ()
310+#else
311+ , testHook = idrisTestHook
312+#endif
284313 }