-
Notifications
You must be signed in to change notification settings - Fork 17
Bitrise logging optimisation v2 #295
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c5da849
Separate closing functions
Badlazzor f9f8c72
Move raw xcbuild logs after filter to ensure waiting for them
Badlazzor d6776b8
Flush sinks after closing filter
Badlazzor 5ab6856
Swap order of closing the filter and the outputs
Badlazzor fba628f
Wait for filter done when closing sinks
Badlazzor 5b80c6a
Use buffer pointer for xcoderaw
Badlazzor 1adf422
Wait for filtering and formatter to close before using the raw output
Badlazzor 3163cb2
Add comments explaining the sync closes without defer
Badlazzor 2d02e15
Separate filter closing and flushing from closing the rest of the piping
Badlazzor 687b1f2
Wrap logging and error checking on filter close
Badlazzor 0b9991a
Fix copy paste in xcpretty logs
Badlazzor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package logio_test | ||
|
|
||
| import ( | ||
| "io" | ||
| "regexp" | ||
| "testing" | ||
|
|
||
| "github.com/bitrise-io/go-xcode/v2/logio" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestPipeWiring(t *testing.T) { | ||
| sut := logio.SetupPipeWiring(regexp.MustCompile(`^\[Bitrise.*\].*`)) | ||
|
|
||
| out := NewChanWriterCloser() | ||
| go func() { | ||
| _, _ = io.Copy(out, sut.ToolStdin) | ||
| _ = out.Close() | ||
| }() | ||
|
|
||
| _, _ = sut.XcbuildStdout.Write([]byte(msg1)) | ||
| _, _ = sut.XcbuildStdout.Write([]byte(msg2)) | ||
| _, _ = sut.XcbuildStdout.Write([]byte(msg3)) | ||
| _, _ = sut.XcbuildStdout.Write([]byte(msg4)) | ||
|
|
||
| _ = sut.Close() | ||
|
|
||
| assert.Equal(t, msg1+msg4, sut.XcbuildRawout.String()) | ||
| assert.Equal(t, msg1+msg4, out.Messages()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't we want to close logging in these cases?
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 comment left there is the key, we have to close the logging before we use the xcbuild raw output. We could leave xcpretty in defer, but at this point we could just explicitly close it with the others.
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.
In this case we're not explicitly calling these in lines 82, 86, 91. But if we opened the pipes we should close them in those cases too, no?
This is why defer is preferable as you don't need to maintain explicit closing, it will just execute after the method exits
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.
Right, I forgot about the other exit points. I get how defer works.
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.
👍🏻 Ok, I see what we want to achieve here now.
In this case I suggest to create an anon method to avoid a lot of duplication