Skip to content

flush stdout after any printed test result #44

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 1 commit into from
Jan 26, 2016

Conversation

phausler
Copy link
Contributor

When running tests from wrappers, such as continuous integration servers, the output of tests may be incorrectly buffered that will result in truncated displaying of tests when failures occur. This behavior incorrectly identifies the wrong test as the failure point in the suites, enforcing a fflush of stdout ensures the buffer is correctly flushed after each marker point for testing.

@modocache
Copy link
Contributor

I like the idea, but how about an internal convenience function that prints, then flushes stdout? That would make it slightly harder for any new print statements that may be added to forget to flush.

When running tests from wrappers, such as continuous integration servers, the output of tests may be incorrectly buffered that will result in truncated displaying of tests when failures occur. This behavior incorrectly identifies the wrong test as the failure point in the suites, enforcing a fflush of stdout ensures the buffer is correctly flushed after each marker point for testing.
@phausler
Copy link
Contributor Author

Fair idea: updated to funnel to a single method wrapping print and fflush (kept the parameters from print just in case)

@briancroom
Copy link
Contributor

I wonder if inserting a call to setlinebuf or setvbuf inside of XCTMain would be simpler than manually calling fflush?

@phausler
Copy link
Contributor Author

as it stands the originating issue for this was to verify a CI failure from Foundation where we were getting a timeout in a test that was not able to get the full output; specifically this was behaving differently than the Mac OS X version. Flushing at each print not only ensures proper output regardless of what may have been potentially mucked with before it. Furthermore it could be reasonable for a test to print multiple lines in the assert, flushing at the print will end up making it flush the entire contents instead of partial contents that setlinebuf may do.

@mike-ferris
Copy link

This seems reasonable, especially when done within a single funnel point like this.

mike-ferris pushed a commit that referenced this pull request Jan 26, 2016
flush stdout after any printed test result
@mike-ferris mike-ferris merged commit 73ff15a into swiftlang:master Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants