Commit 99d0bdf7 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Reuse packagedb in InternalLibraries/Executable/setup-static.test.hs



Otherwise, ghc-pkg will complain that it's reinitializing the
package database.

Possibly there is some refactor to make withPackageDb more robust
if it is called multiple times.

Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 9a3cd918
......@@ -18,34 +18,36 @@ import System.Directory
-- don't get installed, so this test doesn't work on Windows.)
main = setupAndCabalTest $ do
skipUnless =<< hasSharedLibraries
forM_ [False, True] $ \is_dynamic -> withPackageDb $ do
setup_install $ [ if is_dynamic then "--enable-executable-dynamic"
else "--disable-executable-dynamic"
, "--enable-shared"]
dist_dir <- fmap testDistDir getTestEnv
lbi <- liftIO $ getPersistBuildConfig dist_dir
let pkg_descr = localPkgDescr lbi
compiler_id = compilerId (compiler lbi)
cname = CSubLibName $ mkUnqualComponentName "foo-internal"
[target] = componentNameTargets' pkg_descr lbi cname
uid = componentUnitId (targetCLBI target)
InstallDirs{libdir=dir,dynlibdir=dyndir} =
absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest
assertBool "interface files should be installed"
=<< liftIO (doesFileExist (dir </> "Foo.hi"))
assertBool "static library should be installed"
=<< liftIO (doesFileExist (dir </> mkLibName uid))
if is_dynamic
then
assertBool "dynamic library MUST be installed"
=<< liftIO (doesFileExist (dyndir </> mkSharedLibName
compiler_id uid))
else
assertBool "dynamic library should be installed"
=<< liftIO (doesFileExist (dyndir </> mkSharedLibName
compiler_id uid))
fails $ ghcPkg "describe" ["foo"]
-- clean away the dist directory so that we catch accidental
-- dependence on the inplace files
setup "clean" []
runInstalledExe' "foo" [] >>= assertOutputContains "46"
withPackageDb $ do
-- MULTI
forM_ [False, True] $ \is_dynamic -> do
setup_install $ [ if is_dynamic then "--enable-executable-dynamic"
else "--disable-executable-dynamic"
, "--enable-shared"]
dist_dir <- fmap testDistDir getTestEnv
lbi <- liftIO $ getPersistBuildConfig dist_dir
let pkg_descr = localPkgDescr lbi
compiler_id = compilerId (compiler lbi)
cname = CSubLibName $ mkUnqualComponentName "foo-internal"
[target] = componentNameTargets' pkg_descr lbi cname
uid = componentUnitId (targetCLBI target)
InstallDirs{libdir=dir,dynlibdir=dyndir} =
absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest
assertBool "interface files should be installed"
=<< liftIO (doesFileExist (dir </> "Foo.hi"))
assertBool "static library should be installed"
=<< liftIO (doesFileExist (dir </> mkLibName uid))
if is_dynamic
then
assertBool "dynamic library MUST be installed"
=<< liftIO (doesFileExist (dyndir </> mkSharedLibName
compiler_id uid))
else
assertBool "dynamic library should be installed"
=<< liftIO (doesFileExist (dyndir </> mkSharedLibName
compiler_id uid))
fails $ ghcPkg "describe" ["foo"]
-- clean away the dist directory so that we catch accidental
-- dependence on the inplace files
setup "clean" []
runInstalledExe' "foo" [] >>= assertOutputContains "46"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment