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

Special-case FileHandle(forWritingAtPath: "CONOUT$") on Windows. #654

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Aug 30, 2024

This PR special-cases calls to FileHandle.init(forWritingAtPath:) when passed "CONOUT$" (the reserved "console output" file) on Windows such that it does not open a new file but just returns a copy of .stdout instead.

This change is necessary because, on Windows, opening and locking "CONOUT$" does not lock stdout (they're considered entirely different files) and output written to "CONOUT$" is wrapped at the console's column limit even though it's being written as binary data. The VSCode Swift plugin authors would like to be able to specify writing the JSON event stream to "CONOUT$", but the observed behaviour is stopping them from doing so.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR special-cases calls to `FileHandle.init(forWritingAtPath:)` when passed
`"CONOUT$"` (the reserved "console output" file) on Windows such that it does
not open a new file but just returns a copy of `.stdout` instead.

This change is necessary because, on Windows, opening and locking `"CONOUT$"`
does not lock `stdout` (they're considered entirely different files) and output
written to `"CONOUT$"` is wrapped at the console's column limit even though it's
being written as binary data. The VSCode Swift plugin authors would like to be
able to specify writing the JSON event stream to `"CONOUT$"`, but the observed
behaviour is stopping them from doing so.
@grynspan grynspan added bug Something isn't working tools integration Integration of swift-testing into tools/IDEs windows 🪟 Windows support workaround Workaround for an issue in another component (may need to revert later) labels Aug 30, 2024
@grynspan grynspan self-assigned this Aug 30, 2024
@grynspan
Copy link
Contributor Author

@swift-ci test

@dschaefer2
Copy link
Member

LOL, got to love Windows. Nice catch!

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 4c1286e into main Aug 30, 2024
3 checks passed
@grynspan grynspan deleted the jgrynspan/special-case-CONOUT branch August 30, 2024 17:17
@grynspan grynspan added this to the Swift 6.1 milestone Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tools integration Integration of swift-testing into tools/IDEs windows 🪟 Windows support workaround Workaround for an issue in another component (may need to revert later)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants