Skip to content

Fix missing Test Result output on Linux when using print #1401

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

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Feb 23, 2025

node-pty on Linux suffers from a long standing issue where the last chunk of output before a program exits is sometimes dropped, especially if that program produces a lot of output immediately before exiting. See microsoft/node-pty#72

For swift processes that don't require input and may produce a lot of output that could potentially be truncated we can add a new ReadOnlySwiftProcess that spawns a child process using node's built in child_process. These spawned child processes emit their full output before exiting without the need to resort to flakey workarounds on the node-pty process.

When creating new SwiftExecutions in future readOnlyTerminal should be set to true unless the process may require user input.

Issue: #1393

@plemarquand plemarquand force-pushed the linux-missing-last-chunk-terminal-output-fix branch 2 times, most recently from 791cf9f to 0fce1ee Compare February 23, 2025 03:46
@plemarquand plemarquand marked this pull request as draft February 23, 2025 12:30
@plemarquand plemarquand force-pushed the linux-missing-last-chunk-terminal-output-fix branch 5 times, most recently from 78337ff to 7e8505f Compare February 24, 2025 03:54
@plemarquand
Copy link
Contributor Author

I initially tried to work around the issue in node-pty using suggestions in related issues and VS Code itself but because we were using node-pty as a wrapper around a single execution and not as an actual psudoterminal these techniques didn't work.

I like the final approach better anyway since wrapping one off executions like this in a pty seems like overkill.

@plemarquand plemarquand force-pushed the linux-missing-last-chunk-terminal-output-fix branch from 7e8505f to dcafc7e Compare February 24, 2025 14:02
@plemarquand plemarquand marked this pull request as ready for review February 24, 2025 14:13
node-pty on Linux suffers from a long standing issue where the last
chunk of output before a program exits is sometimes dropped, especially
if that program produces a lot of output immediately before exiting.
See microsoft/node-pty#72

For swift processes that don't require input and may produce a lot of
output that could potentially be truncated we can add a new
`ReadOnlySwiftProcess` that spawns a child process using node's built
in `child_process`. These spawned child processes emit their full
output before exiting without the need to resort to flakey workarounds
on the node-pty process.

When creating new `SwiftExecution`s in future `readOnlyTerminal` should
be set to `true` unless the process may require user input.

Issue: swiftlang#1393
@plemarquand plemarquand force-pushed the linux-missing-last-chunk-terminal-output-fix branch from dcafc7e to da26370 Compare February 24, 2025 14:35
@plemarquand plemarquand merged commit eaabdf1 into swiftlang:main Feb 25, 2025
16 checks passed
@plemarquand plemarquand deleted the linux-missing-last-chunk-terminal-output-fix branch February 25, 2025 18:45
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