diff --git a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs index 9da924366f4..0ba522e22c5 100644 --- a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs +++ b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs @@ -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) diff --git a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.out b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.out new file mode 100644 index 00000000000..f8e5532108c --- /dev/null +++ b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.out @@ -0,0 +1,54 @@ +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +Build profile: -w ghc- -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 +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +Build profile: -w ghc- -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 +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Error: [Cabal-7145] +Packages requested to install already exist in environment file at /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 /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Error: [Cabal-7145] +Packages requested to install already exist in environment file at /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 /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Error: [Cabal-7145] +Packages requested to install already exist in environment file at /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 /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Error: [Cabal-7145] +Packages requested to install already exist in environment file at /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 /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... +# cabal v2-install +Wrote tarball sdist to /reinstall.dist/work/./basic/../dist/sdist/basic-0.1.tar.gz +Resolving dependencies... diff --git a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.test.hs b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.test.hs new file mode 100644 index 00000000000..bb0219fc988 --- /dev/null +++ b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/reinstall.test.hs @@ -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"]