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

Add support for combined test output (to land) #1212

Merged
merged 27 commits into from
Jan 9, 2024

Conversation

sunshowers
Copy link
Member

@sunshowers sunshowers commented Jan 9, 2024

This is a version of #1088 that's ready for landing.

The big changes compared to #1088 are:

  • The code to try and manage a single large buffer is all gone, since we never use that functionality and the code was quite complex.
  • We now track some of the other exceptional cases (exec-fail, no-capture) properly instead of trying to shoehorn it all into the stdout/stderr model.
  • I found and fixed some bugs, particularly around custom test harnesses.

Jake-Shadle and others added 23 commits January 2, 2024 09:24
Checkpointing so I can check Windows impl on an actual windows machine
Adds basic tests for TestOutput, particularly the line iterator
While adding tests for the libtestjson output, I noticed that my assumption that stdout/stderr ordering would be _mostly_ correct except in "extreme" scenarios was...completely wrong.

With even the most simple mixed stdout/stderr output (no multithreading, no unbuffered output, no huge single writes) that the ordering of the output was wrong on my machine more often than not. After playing around with the idea of using a pseudo terminal, similar to how alacritty or other terminal emulators work, I checked the even easier case of...just passing the same file descriptor for both stdout and stderr...which works.

Committing this in a separate branch so that I can push and add the Windows implementation before merging this back to the combined output branch.
Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 344 lines in your changes are missing coverage. Please review.

Comparison is base (39600e7) 78.26% compared to head (c504741) 77.39%.

Files Patch % Lines
nextest-runner/src/reporter/aggregator.rs 0.00% 109 Missing ⚠️
nextest-runner/src/test_command/unix.rs 0.00% 104 Missing ⚠️
nextest-runner/src/reporter/structured/libtest.rs 62.65% 59 Missing ⚠️
nextest-runner/src/reporter.rs 50.00% 35 Missing ⚠️
nextest-runner/src/test_output.rs 70.17% 17 Missing ⚠️
nextest-runner/src/runner.rs 76.92% 6 Missing ⚠️
nextest-runner/src/test_command/imp.rs 73.91% 6 Missing ⚠️
nextest-runner/src/list/test_list.rs 54.54% 5 Missing ⚠️
cargo-nextest/src/dispatch.rs 81.81% 2 Missing ⚠️
nextest-runner/src/helpers.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1212      +/-   ##
==========================================
- Coverage   78.26%   77.39%   -0.88%     
==========================================
  Files          69       72       +3     
  Lines       17464    17860     +396     
==========================================
+ Hits        13668    13822     +154     
- Misses       3796     4038     +242     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sunshowers sunshowers merged commit 781ad9f into nextest-rs:main Jan 9, 2024
13 checks passed
@sunshowers sunshowers deleted the combined-output branch January 9, 2024 08:14
sunshowers added a commit that referenced this pull request Jan 9, 2024
For libtest JSON emulation, we need to have a way to model combined stdout and stderr output. The best way to do this happens to be to use the same file descriptor (HANDLE on Windows) for stdout and stderr.

This is pretty useful generally, and in the future we may enable support for combined test output even outside the libtest-json context.

The main alternative considered was having separate fds, but selecting from them into a single giant buffer with tracking indexes into it. However, that doesn't quite work because reading from pipes is done asynchronously with the test process writing to them. This typically causes lines from stdout and stderr to be clumped with each other.

If the same fd is used as in this PR, the test process writes to stdout and stderr *synchronously*, which means that the combined output is recorded in the exact order the test process generates it in.

Enabling combined output does mean that we lose the ability to track outputs separately, but that's not a huge deal.

Co-authored-by: Rain <[email protected]>
@sunshowers
Copy link
Member Author

(the last commit did not have the correct attribution, so I force-pushed one that did)

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.

2 participants