Skip to content

Fixes self-executing scripts not piping plan construction errors from runhaskell to terminal, issue #3942 #4114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 24, 2018
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
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: [email protected]:cjdev/cloudseeder.git
commit: c7068f25c41bcc0b4bdfc9b38ee5b05b5caefae5
extra-dep: true

flags: {}

extra-package-dbs: []