Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Other enhancements:
Bug fixes:

* `~/.stack/config.yaml` and `stack.yaml` terminating by newline
* A regression in recompilation checking introduced in v1.7.1 has been fixed.
See [#4001](https://github.com/commercialhaskell/stack/issues/4001)
* `stack ghci` on a package with internal libraries was erroneously looking
for a wrong package corresponding to the internal library and failing to
load any module. This has been fixed now and changes to the code in the
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ getPackageFilesForTargets
getPackageFilesForTargets pkg cabalFP nonLibComponents = do
(components',compFiles,otherFiles,warnings) <-
getPackageFiles (packageFiles pkg) cabalFP
let components = M.keysSet components' `Set.union` nonLibComponents
let necessaryComponents = Set.insert CLib $ Set.filter isCInternalLib (M.keysSet components')
components = necessaryComponents `Set.union` nonLibComponents
componentsFiles =
M.map (\files -> Set.union otherFiles (Set.map dotCabalGetPath files)) $
M.filterWithKey (\component _ -> component `Set.member` components) compFiles
Expand Down
19 changes: 19 additions & 0 deletions test/integration/tests/4001-excess-recompilation/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Control.Monad (unless)
import Data.List (isInfixOf)
import StackTest

main :: IO ()
main = do
copy "test/Main1.hs" "test/Main.hs"
copy "bench/Main1.hs" "bench/Main.hs"
stack ["build"]

copy "test/Main2.hs" "test/Main.hs"
copy "bench/Main2.hs" "bench/Main.hs"
res <- unregisteringLines . snd <$> stackStderr ["build"]
removeFileIgnore "test/Main.hs"
removeFileIgnore "bench/Main.hs"
unless (null res) $ fail "Stack recompiled when a test or benchmark file was changed, but only the library was targeted"

unregisteringLines :: String -> [String]
unregisteringLines = filter (isInfixOf " unregistering ") . lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Lib

main :: IO ()
main = putStrLn "I am Main1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Lib

main :: IO ()
main = putStrLn "I am Main2"

25 changes: 25 additions & 0 deletions test/integration/tests/4001-excess-recompilation/files/files.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: files
version: 0.1.0.0
build-type: Simple
cabal-version: >= 2.0

library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base
default-language: Haskell2010

test-suite test
hs-source-dirs: test
main-is: Main.hs
build-depends: base, files
default-language: Haskell2010
type: exitcode-stdio-1.0

benchmark bench
hs-source-dirs: bench
main-is: Main.hs
build-depends: base, files
default-language: Haskell2010
type: exitcode-stdio-1.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Lib where

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver: ghc-8.2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Lib

main :: IO ()
main = putStrLn "I am Main1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Lib

main :: IO ()
main = putStrLn "I am Main2"