Skip to content

Commit

Permalink
Merge pull request #158 from wjdp/flaky-test
Browse files Browse the repository at this point in the history
Fix flaky test (TestAnchorExternalHrefIPTimeout)
  • Loading branch information
wjdp committed Jan 15, 2021
2 parents 22b5824 + a65ff20 commit 0dfa159
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions htmltest/check-link.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,6 @@ func (hT *HTMLTest) checkExternal(ref *htmldoc.Reference) {
<-hT.httpChannel // Bump off http concurrency limiter

if err != nil {
if strings.Contains(err.Error(), "dial tcp") {
// Remove long prefix
prefix := "Get " + urlStr + ": dial tcp: lookup "
cleanedMessage := strings.TrimPrefix(err.Error(), prefix)
// Add error
hT.issueStore.AddIssue(issues.Issue{
Level: issueLevel,
Message: cleanedMessage,
Reference: ref,
})
return
}
if strings.Contains(err.Error(), "Client.Timeout") {
hT.issueStore.AddIssue(issues.Issue{
Level: issueLevel,
Expand All @@ -215,6 +203,20 @@ func (hT *HTMLTest) checkExternal(ref *htmldoc.Reference) {
}
}

// More generic, should be kept below more specific cases
if strings.Contains(err.Error(), "dial tcp") {
// Remove long prefix
prefix := "Get " + urlStr + ": dial tcp: lookup "
cleanedMessage := strings.TrimPrefix(err.Error(), prefix)
// Add error
hT.issueStore.AddIssue(issues.Issue{
Level: issueLevel,
Message: cleanedMessage,
Reference: ref,
})
return
}

// Unhandled client error, return generic error
hT.issueStore.AddIssue(issues.Issue{
Level: issueLevel,
Expand Down
2 changes: 1 addition & 1 deletion htmltest/test_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func tExpectIssue(t *testing.T, hT *HTMLTest, message string, expected int) {
c := hT.issueStore.MessageMatchCount(message)
if c != expected {
hT.issueStore.DumpIssues(true)
t.Error("expected issue", message, "count", expected, "!=", c)
t.Error("expected issue", "'"+message+"'", "count", expected, "!=", c)
}
}

Expand Down

0 comments on commit 0dfa159

Please sign in to comment.