-
Notifications
You must be signed in to change notification settings - Fork 12
[CI-267] Command errors #174
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
command/command.go
Outdated
| } | ||
|
|
||
| func (c command) wrappedOutputBuffers() (*bytes.Buffer, *bytes.Buffer) { | ||
| var outBuffer, errBuffer bytes.Buffer |
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.
This way, we capture the full combined output of the commands, which can take relatively big memory in case of some commands (like xcodebuild).
What about creating a custom Writer (for example, ErrorFinderWriter), which is constructed with the ErrorFinder function and runs when Write is called?
This way we don't need to hold the whole command output in memory and can be similar set for the cmd.Stdout and cmd.Stderr to the current implementation
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.
The only outstanding question regarding this solution was that what is happening with multiline errors. Do they delivered in one go or are they going to be split up. Well I tried it and it seems like they are delivered in one chunk and this can the right solution.
I have a sample run where I referenced non existing simulators and this multiline error was a single chunk:
error collector | Received output: xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:EF348E33-8191-4224-8DB6-85F27F701000 }
The requested device could not be found because no available devices matched the request.
Available destinations for the "FlakyTests" scheme:
{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-000C614614BB001E }
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
{ platform:iOS Simulator, id:E2A5A03C-E1EB-4FF2-9D77-56ADD545D094, OS:16.1, name:iPad (10th generation) }
{ platform:iOS Simulator, id:92E16292-4848-4A86-8151-39EE589CCD5E, OS:16.1, name:iPad Air (5th generation) }
{ platform:iOS Simulator, id:3698CDAB-A354-4AE8-8D0B-1A6DA49B05E0, OS:16.1, name:iPad Pro (11-inch) (4th generation) }
{ platform:iOS Simulator, id:F85507B3-0C4B-4103-9745-4DEE678C786B, OS:16.1, name:iPad Pro (12.9-inch) (2nd generation) }
{ platform:iOS Simulator, id:8F2138A2-40BF-4CAE-8AA9-CCAE5B4BBFD1, OS:16.1, name:iPad Pro (12.9-inch) (6th generation) }
{ platform:iOS Simulator, id:52C04C69-0F4E-486C-BC43-ADAD4DB73C35, OS:16.1, name:iPad mini (6th generation) }
{ platform:iOS Simulator, id:D0D80222-0FE8-49A3-B9D6-ACAD161DF0CF, OS:16.1, name:iPhone 8 Plus }
{ platform:iOS Simulator, id:AB22472D-1951-4F3B-8DBD-3905533528DA, OS:16.1, name:iPhone 11 Pro Max }
{ platform:iOS Simulator, id:8D2FE8B8-DA74-4ED4-B6C4-181340DB9991, OS:16.1, name:iPhone 14 }
{ platform:iOS Simulator, id:8A2787A8-B6B7-49DF-ABE2-CD2C6F5C78AA, OS:16.1, name:iPhone 14 Plus }
{ platform:iOS Simulator, id:E2A7D25B-9AB5-4279-AB5C-FFA6DFBE99AA, OS:16.1, name:iPhone 14 Pro }
{ platform:iOS Simulator, id:A4F566D1-D7EB-4416-9A78-747D48ABE498, OS:16.1, name:iPhone 14 Pro Max }
{ platform:iOS Simulator, id:B5ED6FAF-C16D-4EBC-875E-10761B76B88D, OS:16.1, name:iPhone SE (3rd generation) }
So I have updated the PR with a new error collector struct which implements the io.Writer interface. This collector runs the error finding function on the received output and stores the found error lines.
This PR adds better command error handling to all of the command runnner functions. This means that instead of just writing
to the output it will add the command details to the error like
It also supports custom error finding logic. This means it feeds the stderr and stdout outputs through this error finder which can return additional error lines. For example, with this we can easily fetch additional xcodebuild errors and add them as failure reasons. Here is a real life example