Skip to content

Commit

Permalink
Check correct directory deletion behaviour for simple project
Browse files Browse the repository at this point in the history
-  The integration test ensures the correct directories are present,
then deleted, for a project with only one package, not in a
subdirectory.
  • Loading branch information
dbaynard committed Feb 10, 2019
1 parent 97f280b commit 893a8b7
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions test/integration/tests/3863-purge-command/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
import StackTest
import Data.Maybe (listToMaybe, fromMaybe)
import System.Directory
import System.FilePath

main :: IO ()
main = do
stack ["build"]
stack ["purge"]
main =
-- For these commands, we'll need to know the `dist` directory.
-- This is usually `.stack-work/dist/$compiler-variant/Cabal-xxxx`
stackCheckStdout [defaultResolverArg, "path", "--dist-dir"] $ \distDir ->

stackCheckStdout [defaultResolverArg, "path", "--local-install-root"] $ \localInstallRoot -> do

-- Usually `.stack-work`
let stackWork = fromMaybe (error "There must be a stack working directory.") $
listToMaybe (splitDirectories distDir)

-- First, clean the .stack-work directory.
-- This is only necessary when running individual tests.
stack [defaultResolverArg, "purge"]
doesNotExist stackWork

-- The dist directory should exist after a build
stack [defaultResolverArg, "build"]
doesExist distDir
doesExist localInstallRoot
doesExist stackWork

-- The dist directory should not exist after a clean, whereas the
-- .stack-work directory should
stack [defaultResolverArg, "clean"]
run "exa" ["-T", ".stack-work"]
doesNotExist distDir
doesExist localInstallRoot
doesExist stackWork

-- The .stack-work directory should not exist after a purge
stack [defaultResolverArg, "purge"]
doesNotExist stackWork

0 comments on commit 893a8b7

Please sign in to comment.