-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build all exes once; then only specified (#3229)
- Loading branch information
Showing
6 changed files
with
170 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- | Stack should build all executables once, and in subsequent | ||
-- invocations only build those executables requested by the program | ||
-- arguments. | ||
-- | ||
-- Issue: https://github.com/commercialhaskell/stack/issues/3229 | ||
|
||
module Main where | ||
|
||
import Control.Exception | ||
import Control.Monad (unless, when) | ||
import qualified Data.ByteString as S | ||
import Data.List (isInfixOf) | ||
import StackTest | ||
|
||
main :: IO () | ||
main = do | ||
stack [defaultResolverArg, "clean", "--full"] | ||
stack [defaultResolverArg, "init", "--force"] | ||
stackCheckStderr | ||
["build", ":alpha"] | ||
(expectMessage | ||
(unlines | ||
[ "Building all executables once. After a successful build of all of them, only specified executables will be rebuilt." | ||
])) | ||
bracket | ||
(S.readFile alphaFile) | ||
(S.writeFile alphaFile) | ||
(const | ||
(do appendFile alphaFile "\n--" | ||
stackCheckStderr | ||
["build", ":alpha"] | ||
(rejectMessage | ||
(unlines | ||
["Preprocessing executable 'beta' for foo-0..."])))) | ||
where | ||
alphaFile = "app/Alpha.hs" | ||
|
||
expectMessage :: String -> String -> IO () | ||
expectMessage msg stderr = | ||
unless (msg `isInfixOf` stderr) | ||
(error $ "Expected in output: \n" ++ show msg) | ||
|
||
rejectMessage :: String -> String -> IO () | ||
rejectMessage msg stderr = | ||
when (msg `isInfixOf` stderr) | ||
(error $ "Did not expect message here: \n" ++ show msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main = return () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main = return () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: foo | ||
version: 0 | ||
build-type: Simple | ||
cabal-version: >=1.10 | ||
|
||
library | ||
hs-source-dirs: src | ||
exposed-modules: Foo | ||
build-depends: base >= 4.7 && < 5 | ||
default-language: Haskell2010 | ||
|
||
executable alpha | ||
hs-source-dirs: app | ||
main-is: Alpha.hs | ||
build-depends: base, foo | ||
default-language: Haskell2010 | ||
|
||
executable beta | ||
hs-source-dirs: app | ||
main-is: Beta.hs | ||
build-depends: base, foo | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module Foo where |