Skip to content

Commit

Permalink
Fix clean bug uncovered by 5fad121
Browse files Browse the repository at this point in the history
- clean was trying to read source-builds even if it didn't exist
- add test specific to this case with other clean tests
  • Loading branch information
bacchanalia authored and mergify-bot committed Dec 31, 2021
1 parent d379d22 commit 4e03925
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/CmdClean.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ cleanAction CleanFlags{..} extraArgs _ = do
-- It would be better as part of an explicit gc step (see issue #3333)
toClean <- Set.fromList <$> mapM canonicalizePath extraArgs
cacheDir <- getScriptCacheDirectoryRoot
caches <- listDirectory cacheDir
existsCD <- doesDirectoryExist cacheDir
caches <- if existsCD then listDirectory cacheDir else return []
paths <- fmap concat . forM caches $ \cache -> do
let locFile = cacheDir </> cache </> "scriptlocation"
exists <- doesFileExist locFile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# cabal v2-clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude
import System.Environment (setEnv)
import Distribution.Client.ScriptUtils (getScriptCacheDirectory)

main = cabalTest . void $ do
cabal' "v2-clean" ["script.hs"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{- cabal:
build-depends: base
-}

main :: IO ()
main = putStrLn "Hello World"

0 comments on commit 4e03925

Please sign in to comment.