Skip to content

Commit

Permalink
Merge pull request #4114 from SkyWriter/feature/self-exec
Browse files Browse the repository at this point in the history
Fixes self-executing scripts not piping plan construction errors from runhaskell to terminal, issue #3942
  • Loading branch information
isovector authored Jun 24, 2018
2 parents 9d0bcdc + 2383d8a commit 466da22
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Bug fixes:
was a package with a sublibrary in the snapshot resulted in broken builds.
This is now fixed, see
[#4071](https://github.com/commercialhaskell/stack/issues/4071).
* [#4114] Stack pretty prints error messages with proper `error` logging
level instead of `warning` now. This also fixes self-executing scripts
not piping plan construction errors from runhaskell to terminal (issue
#3942).


## v1.7.1
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ prettyErrorWith f = prettyWith LevelError
indentAfterLabel . f)
prettyWarnNoIndentWith f = prettyWith LevelWarn
((line <>) . (styleWarning "Warning:" <+>) . f)
prettyErrorNoIndentWith f = prettyWith LevelWarn
prettyErrorNoIndentWith f = prettyWith LevelError
((line <>) . (styleError "Error:" <+>) . f)

prettyDebug, prettyInfo, prettyNote, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent
Expand Down
16 changes: 16 additions & 0 deletions test/integration/tests/3942-solver-error-output/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Control.Monad (unless)
import Data.List (isInfixOf)
import StackTest

planFailure :: String
planFailure =
"While constructing the build plan, the following exceptions were encountered:"

main :: IO ()
main = do
stackErrStderr ["./script.hs"] (expectMessage planFailure)

expectMessage :: String -> String -> IO ()
expectMessage msg stderr = do
unless (words msg `isInfixOf` words stderr)
(error $ "Expected a warning: \n" ++ show msg)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.stack-work/
*.cabal
stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env stack
-- stack runhaskell --stack-yaml test-stack.yml --package cloud-seeder

main :: IO ()
main = putStrLn "yo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resolver: lts-8.22

packages:
- location:
git: git@github.com:cjdev/cloudseeder.git
commit: c7068f25c41bcc0b4bdfc9b38ee5b05b5caefae5
extra-dep: true

flags: {}

extra-package-dbs: []

0 comments on commit 466da22

Please sign in to comment.