From 2d792c938ac59b383946b5ad94b792d225673cb6 Mon Sep 17 00:00:00 2001 From: Will Pimblett Date: Fri, 15 Jan 2021 21:59:05 +0000 Subject: [PATCH 1/2] Add quotes around message in tExpectIssue Makes it easier to see what the message we were expecting. --- htmltest/test_helpers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htmltest/test_helpers_test.go b/htmltest/test_helpers_test.go index 676fd2d..b84f53c 100644 --- a/htmltest/test_helpers_test.go +++ b/htmltest/test_helpers_test.go @@ -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) } } From a65ff20693b96e82c3e9d72ecb3e80e206e57194 Mon Sep 17 00:00:00 2001 From: Will Pimblett Date: Fri, 15 Jan 2021 21:59:38 +0000 Subject: [PATCH 2/2] Fix bad error handling in checkExternal Sometimes the error message from http.Client is different in Go 1.15 for client timeouts. The messages causing issues contain "dial tcp" which was caught before Client.Timeout. This fix just moves the handler for "Client.Timeout" above "dial tcp". Will close #148 --- htmltest/check-link.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htmltest/check-link.go b/htmltest/check-link.go index f28b96f..2987f3b 100644 --- a/htmltest/check-link.go +++ b/htmltest/check-link.go @@ -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, @@ -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,