Skip to content

Commit

Permalink
Add reinstall test to LinkerOptions/NonignoredConfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Oct 22, 2023
1 parent 6c69db7 commit 851e598
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ main = cabalTest $ do
withDirectory ".." $ do
packageEnv <- (</> ("basic" ++ show idx ++ ".env")) . testWorkDir <$> getTestEnv
cabal "v2-install" $ ["--disable-deterministic", "--lib", "--package-env=" ++ packageEnv] ++ linkConfigFlags linking ++ ["basic"]
cabal "v2-install" $ ["--disable-deterministic", "--lib", "--package-env=" ++ packageEnv] ++ linkConfigFlags linking ++ ["basic"]
let exIPID s = takeWhile (/= '\n') . head . filter (\t -> any (`isPrefixOf` t) ["basic-0.1-", "bsc-0.1-"]) $ tails s
hashedIpid <- exIPID <$> liftIO (readFile packageEnv)
return $ ((idx, linking), hashedIpid)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- basic-0.1 (lib) (requires build)
Configuring library for basic-0.1...
Preprocessing library for basic-0.1...
Building library for basic-0.1...
Installing library in <PATH>
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- basic-0.1 (lib) (requires build)
Configuring library for basic-0.1...
Preprocessing library for basic-0.1...
Building library for basic-0.1...
Installing library in <PATH>
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Error: [Cabal-7145]
Packages requested to install already exist in environment file at <ROOT>/reinstall.dist/basic0.env. Overwriting them may break other packages. Use --force-reinstalls to proceed anyway. Packages: basic
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Error: [Cabal-7145]
Packages requested to install already exist in environment file at <ROOT>/reinstall.dist/basic1.env. Overwriting them may break other packages. Use --force-reinstalls to proceed anyway. Packages: basic
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Error: [Cabal-7145]
Packages requested to install already exist in environment file at <ROOT>/reinstall.dist/basic2.env. Overwriting them may break other packages. Use --force-reinstalls to proceed anyway. Packages: basic
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Error: [Cabal-7145]
Packages requested to install already exist in environment file at <ROOT>/reinstall.dist/basic3.env. Overwriting them may break other packages. Use --force-reinstalls to proceed anyway. Packages: basic
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
# cabal v2-install
Wrote tarball sdist to <ROOT>/reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz
Resolving dependencies...
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Test.Cabal.Prelude

import Control.Monad (forM, foldM_)
import Data.List (isPrefixOf, tails)

data Linking = Static | Dynamic deriving (Eq, Ord, Show)

links :: [Linking]
links = [Static, Dynamic]

linkConfigFlags :: Linking -> [String]
linkConfigFlags Static =
[
]
linkConfigFlags Dynamic =
[
"--enable-shared",
"--enable-executable-dynamic",
"--disable-library-vanilla"
]

lrun :: [Linking]
lrun = [Static, Dynamic, Static, Dynamic]

main = cabalTest $ do
skipIfWindows
withPackageDb $ do
forM_ (zip [0..] lrun) $ \(idx, linking) -> do
withDirectory "basic" $ do
withSourceCopyDir ("basic" ++ show idx) $ do
withDirectory ".." $ do
packageEnv <- (</> ("basic" ++ show idx ++ ".env")) . testWorkDir <$> getTestEnv
cabal "v2-install" $ ["--disable-deterministic", "--lib", "--package-env=" ++ packageEnv] ++ linkConfigFlags linking ++ ["basic"]
forM_ (zip [0..] lrun) $ \(idx, linking) -> do
withDirectory "basic" $ do
withSourceCopyDir ("basic" ++ show idx) $ do
withDirectory ".." $ do
packageEnv <- (</> ("basic" ++ show idx ++ ".env")) . testWorkDir <$> getTestEnv
fails $ cabal "v2-install" $ ["--disable-deterministic", "--lib", "--package-env=" ++ packageEnv] ++ linkConfigFlags linking ++ ["basic"]
forM_ (zip [0..] lrun) $ \(idx, linking) -> do
withDirectory "basic" $ do
withSourceCopyDir ("basic" ++ show idx) $ do
withDirectory ".." $ do
packageEnv <- (</> ("basic" ++ show idx ++ ".env")) . testWorkDir <$> getTestEnv
cabal "v2-install" $ ["--force-reinstalls", "--disable-deterministic", "--lib", "--package-env=" ++ packageEnv] ++ linkConfigFlags linking ++ ["basic"]

0 comments on commit 851e598

Please sign in to comment.