This repository has been archived by the owner on Apr 12, 2019. It is now read-only.
forked from gogs/git-module
-
Notifications
You must be signed in to change notification settings - Fork 42
Rectify error handling #44
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
package git | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
) | ||
|
@@ -32,10 +33,7 @@ func TestRunInDirTimeoutPipelineAlwaysTimeout(t *testing.T) { | |
cmd := NewCommand("hash-object --stdin") | ||
for i := 0; i < maxLoops; i++ { | ||
if err := cmd.RunInDirTimeoutPipeline(1*time.Microsecond, "", nil, nil); err != nil { | ||
// 'context deadline exceeded' when the error is returned by exec.Start | ||
// 'signal: killed' when the error is returned by exec.Wait | ||
// It depends on the point of the time (before or after exec.Start returns) at which the timeout is triggered. | ||
if err.Error() != "context deadline exceeded" && err.Error() != "signal: killed" { | ||
if err != context.DeadlineExceeded { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you want to remove documentation in those comments ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since that is encapsulated into RunInDirTimeoutPipeline and the test won't be exposed to the nuances anymore (which is what I hope for). |
||
t.Fatalf("Testing %d/%d: %v", i, maxLoops, err) | ||
} | ||
} | ||
|
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.
And what happens to
err
? Looks like simply getting lost ?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.
how about swapping the conditiona and returning err if not nil and return nil outside the condition block ?
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 err returned by exec.Wait is discarded in favor of ctx.Err(). Because exec.Wait() will returns a string 'signal: killed', which isn't good to depend on and is less meaningful. I don't have a good idea to encode the two errors (exec.Wait's and ctx.Err's) into one cleanly either.
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.
Maybe just log it ?
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.
Do you mean logging the error of Wait and returning the error of ctx.Err() or something else?
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.
Yes log the error of Wait
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.
Done.