Skip to content
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

missing newline at the end of "Progress: 1/2" #1302

Closed
FranklinYu opened this issue Nov 7, 2015 · 13 comments
Closed

missing newline at the end of "Progress: 1/2" #1302

FranklinYu opened this issue Nov 7, 2015 · 13 comments
Milestone

Comments

@FranklinYu
Copy link

When I run stack test the newline is missing, so this line and next (testing message in my case) are concatenated into one. I found the source at Execute.hs but I have no idea how to fix it since I am a Haskell newbie. Minor bug, but should be easy to fix (I assume).

@rubik
Copy link
Contributor

rubik commented Nov 7, 2015

I noticed this bug as well. It would suffice to add <> "\n" at the end, but I find it very strange that logSticky does not append newlines automatically. In fact, searching for occurrences of logSticky in Stack's source shows that it's never used with newlines:
https://github.com/commercialhaskell/stack/search?utf8=%E2%9C%93&q=logsticky

So the problem must be somewhere else.

@FranklinYu
Copy link
Author

@rubik I read the description of logSticky; it says that we need logStickyDone if we need the trailing newline. Actually I should not have seen the "Progress: 1/2" in the final output; output after logStickyDone should have overwritten this line, and this happens (as expected) if nothing is printed during test, i.e.,

main :: IO ()
main = return ()

So basically any output in test suite, even as simple as

main :: IO ()
main = putStrLn "test"

will break the logSticky and leave the "Progress 1/2" in final output.

@FranklinYu
Copy link
Author

One of the template, new-template, serves as an example of this bug.

@rubik
Copy link
Contributor

rubik commented Nov 11, 2015

Well done @FranklinYu, I can confirm what you said. My test suite uses Hspec and Stack's output is hijacked because of this. One possible solution could be to suspend the progress status during tests and resume it right after. This is not very easy to do because the function executePlan' is used for many things, not only tests.

@borsboom
Copy link
Contributor

I think Stack should be capturing the output of the tests (and benchmarks, which I suspect will have the same problem) and re-emitting it in a way that's friendly to the sticky progress, the same way as it does for GHC output.

@FranklinYu
Copy link
Author

@borsboom Yes I think that is a better solution!

mgsloan added a commit that referenced this issue Dec 12, 2015
mgsloan added a commit that referenced this issue Dec 12, 2015
+ add a trailing newline to test output
@mgsloan
Copy link
Contributor

mgsloan commented Dec 12, 2015

There were two issues here:

  • runActions wasn't waiting for the progress thread to finish its work before exiting, so we wouldn't always get the $logStickyDone message that actions completed.
  • Test output is being directly sent to stack's stdout / stderr, without first clearing the sticky message. It now clears the sticky message before running the test.

Please reopen if not resolved in the development version.

@mgsloan mgsloan closed this as completed Dec 12, 2015
mgsloan added a commit that referenced this issue Dec 14, 2015
@borsboom
Copy link
Contributor

I'm reopening this since the fix was reverted.

@borsboom borsboom reopened this Dec 24, 2015
@mgsloan
Copy link
Contributor

mgsloan commented Dec 26, 2015

Good catch! I thought 68ef027 was sufficient, but turns out that you still get the "Progress 1/2" message. Weird!

@mgsloan
Copy link
Contributor

mgsloan commented Jan 10, 2016

Fixed!

@mgsloan mgsloan closed this as completed Jan 10, 2016
@mgsloan
Copy link
Contributor

mgsloan commented Jan 21, 2016

Darn, the resolution to #1685 brought this back

@mgsloan mgsloan reopened this Jan 21, 2016
@mgsloan
Copy link
Contributor

mgsloan commented Jun 17, 2016

I don't have time to work on this right now, but I have a theory it may be due to hPutStrLn h t = hPutStr h t >> hPutChar h '\n' in Data.Text. Concurrent execution can cause other output to be inserted between your text and the newline.

@snoyberg
Copy link
Contributor

I believe this is actually resolved now, please ping or open a new issue if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants