-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Parse XCbuild stderr only if stdout is empty #3584
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
let redirection: Process.OutputRedirection = .stream(stdout: delegate.parse(bytes:), stderr: { bytes in | ||
self.diagnostics.emit(StringError(String(bytes: bytes, encoding: .utf8)!)) | ||
if let str = String(bytes: bytes, encoding: .utf8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably String(decoding: bytes, as: UTF8.self)
is better here since it decodes as much content as possible even if there is invalid output.
let redirection: Process.OutputRedirection = .stream(stdout: delegate.parse(bytes:), stderr: { bytes in | ||
self.diagnostics.emit(StringError(String(bytes: bytes, encoding: .utf8)!)) | ||
if let str = String(bytes: bytes, encoding: .utf8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is it the right thing to emit all of this output as warnings? If I have an error that is emitted, would it show up as parseable diagnostics as well as on stderr, and thus show up as a warning as well as an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what the report in the radar seems to suggest. @jakepetroules Could you confirm the above question? Or would we need to filter and treat certain stderr as actual errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All XCBuild output is communicated as structured (JSON) data via stdout, if we emit anything via stderr it's unintentional and can be dropped.
@swift-ci smoke test |
@swift-ci smoke test |
@swift-ci smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks!
}) | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line (format)
@swift-ci smoke test |
SwiftPM parses all stderr output from XCBuild that shouldn't lead to a build failure, but emits it as an error diagnostic, which does lead to it. Diagnostics are already available via the parseable JSON output on stdout, not textually via stderr.
Motivation:
Resolves rdar://75751711 (SwiftPM is parsing ALL stderr output from XCBuild into an error diagnostic that fails the build).
Modifications:
This change parses XCBuild stderr and emits error only if stdout is empty.
Result:
If XCBuild stdout is not empty, stderr is now ignored, else it will throw a build error.