Skip to content

Commit

Permalink
Add dirty and clean install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Oct 29, 2023
1 parent 11d11a7 commit 71bf9be
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cabal-version: 3.0
name: WarnEarlyOverwrite
version: 0.1.0.0
license: BSD-3-Clause
author: Phil de Joux
build-type: Simple

common warnings
ghc-options: -Wall

executable warn-early-overwrite
import: warnings
main-is: Main.hs
build-depends: base
hs-source-dirs: app
default-language: Haskell2010
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/WarnEarlyOverwrite/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = putStrLn "Early warning"
12 changes: 12 additions & 0 deletions cabal-testsuite/PackageTests/WarnEarlyOverwrite/clean-install.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal v2-install
Wrote tarball sdist to <ROOT>/clean-install.dist/work/./dist/sdist/WarnEarlyOverwrite-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- WarnEarlyOverwrite-0.1.0.0 (exe:warn-early-overwrite) (requires build)
Configuring executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Preprocessing executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Building executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Installing executable warn-early-overwrite in <PATH>
Warning: The directory <GBLTMPDIR>/ghc-<GHCVER>/incoming/new-<RAND><GBLTMPDIR>/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path.
Symlinking 'warn-early-overwrite' to '<GBLTMPDIR>/warn-early-overwrite'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

main = withShorterPathForNewBuildStore $ \storeDir -> cabalTest $ do
let options = ["--store-dir=" ++ storeDir, "--installdir=" ++ storeDir]
cabalG options "v2-install" []
20 changes: 20 additions & 0 deletions cabal-testsuite/PackageTests/WarnEarlyOverwrite/dirty-install.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# cabal v2-install
Wrote tarball sdist to <ROOT>/dirty-install.dist/work/./dist/sdist/WarnEarlyOverwrite-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- WarnEarlyOverwrite-0.1.0.0 (exe:warn-early-overwrite) (requires build)
Error: [Cabal-7149]
Path '<GBLTMPDIR>/warn-early-overwrite' already exists. Use --overwrite-policy=always to overwrite.
# cabal v2-install
Wrote tarball sdist to <ROOT>/dirty-install.dist/work/./dist/sdist/WarnEarlyOverwrite-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- WarnEarlyOverwrite-0.1.0.0 (exe:warn-early-overwrite) (requires build)
Configuring executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Preprocessing executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Building executable 'warn-early-overwrite' for WarnEarlyOverwrite-0.1.0.0...
Installing executable warn-early-overwrite in <PATH>
Warning: The directory <GBLTMPDIR>/ghc-<GHCVER>/incoming/new-<RAND><GBLTMPDIR>/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path.
Symlinking 'warn-early-overwrite' to '<GBLTMPDIR>/warn-early-overwrite'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Test.Cabal.Prelude

import System.FilePath

main = withShorterPathForNewBuildStore $ \storeDir -> cabalTest $ do
let options = ["--store-dir=" ++ storeDir, "--installdir=" ++ storeDir]
-- Touch the target to see if the warning is made early before the build.
_ <- runM "touch" [storeDir </> "warn-early-overwrite"] Nothing
fails $ cabalG options "v2-install" []
cabalG options "v2-install" ["--overwrite-policy=always"]

0 comments on commit 71bf9be

Please sign in to comment.