question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON reporter output appears in Debug Console and results not updated when writing output to stdout without newlines

See original GitHub issue
void main() {
  test('foo', () {
    stdout.write('foo');
  });
}
Screenshot 2022-08-03 at 12 27 32

Using writeln prevents the issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakemac53commented, Aug 3, 2022

I looked into this a little bit, and chatted with @natebosch about it as well.

There are a few challenges involved generally, such as what to do if somebody writes arbitrary bytes, the fact that reporters can’t unconditionally import dart:io at all, etc. Also customizing things just for the json reporter also is not very clean to do and would require a fair bit of plumbing.

The general consensus we reached is as follows:

  • Always override stdout/stderr, so we don’t break our output.
  • Always convert Strings into normal print messages, probably using the line splitter to only send messages when we get a newline (this would be a bit of a behavior change if we wait for newlines). We may prefix the strings with Stdout: and/or Stderr: etc.
  • For raw bytes, first attempt to decode them with the current encoding.
    • If we can, then treat the result like a normal String.
    • If we can’t, then just emit either the base 64 encoded bytes or a character or message indicating an invalid string.
  • For the rest of the Stdout api:
    • hasTerminal: always returns false
    • terminalColumns: always throws
    • terminalLines: always throws
    • nonBlocking: returns this
    • addError: add the error to the error stream controller

If people are relying on the existing behavior in some way, we can address that on a case by case basis, but most likely the answer will just be that they should use their own IOOverrides to get different behavior if needed.

0reactions
DanTupcommented, Aug 4, 2022

Sounds reasonable to me. Since it sounds like this can all be solved in pkg:test, I’ve opened https://github.com/dart-lang/test/issues/1749 and will close this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How do you get VS Code to write Debug stdout to the ...
When I try to print out any statement, such as using > print("here") I do not get any output to the Debug Console....
Read more >
Pylint output - Pylint 2.16.0-dev documentation
Output by default is written to stdout. The simplest way to output to a file is with the --output=<filename> option. The default format...
Read more >
Debugging - Cypress Documentation
You can see a walk-through of debugging some application code from Cypress in this segment from our React tutorial series. Get console logs...
Read more >
Component Reference - Apache JMeter - User's Manual
Several test elements use JMeter properties to control their behaviour. These properties are normally resolved when the class is loaded.
Read more >
Configuration File | API | Docs - TestCafe
You can use multiple reporters, but note that only one reporter can write to stdout . All other reporters must output to files....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found