From 0839658c8d2dd95969d5463da9877dfa716d5fc6 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sun, 20 Oct 2019 12:26:32 -0700 Subject: [PATCH] Fix the failing tests, include Go 1.13 in test matrix --- .travis.yml | 1 + src/util.ts | 14 +++++++++++++- test/fixtures/gogetdocTestData/test.go | 4 ++-- test/integration/extension.test.ts | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98c8c194..bce9efd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ go: - 1.10.x - 1.11.x - 1.12.x + - 1.13.x - tip matrix: diff --git a/src/util.ts b/src/util.ts index 995700ee..cd91f72e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -940,7 +940,20 @@ export function runGodoc(cwd: string, packagePath: string, receiver: string, sym if (err) { return reject(err.message || stderr); } + let doc = ''; const godocLines = stdout.split('\n'); + if (!godocLines.length) { + return resolve(doc); + } + + // Recent versions of Go have started to include the package statement + // tht we dont need. + if (godocLines[0].startsWith('package ')) { + godocLines.splice(0, 1); + if (!godocLines[0].trim()) { + godocLines.splice(0, 1); + } + } // Skip trailing empty lines let lastLine = godocLines.length - 1; @@ -950,7 +963,6 @@ export function runGodoc(cwd: string, packagePath: string, receiver: string, sym } } - let doc = ''; for (let i = 1; i <= lastLine; i++) { if (godocLines[i].startsWith(' ')) { doc += godocLines[i].substring(4) + '\n'; diff --git a/test/fixtures/gogetdocTestData/test.go b/test/fixtures/gogetdocTestData/test.go index 83749c35..ecf25643 100644 --- a/test/fixtures/gogetdocTestData/test.go +++ b/test/fixtures/gogetdocTestData/test.go @@ -26,7 +26,7 @@ func main() { // Hello is a method on the struct ABC. Will signature help understand this correctly func (abcd *ABC) Hello(s string, exclaim bool) string { - net.CIDRMask(10, 20) + net.IPv4Mask(0, 0, 0, 0) if exclaim { s = s + "!" } @@ -47,4 +47,4 @@ func Greetings() string { // with a blank line in the middle func EmptyLine(s string) string { return s + "this is not an empty line" -} \ No newline at end of file +} diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts index cf7cfb48..c37adbe6 100644 --- a/test/integration/extension.test.ts +++ b/test/integration/extension.test.ts @@ -248,7 +248,7 @@ It returns the number of bytes written and any write error encountered. [new vscode.Position(40, 23), 'package math', 'Package math provides basic constants and mathematical functions.\n\nThis package does not guarantee bit-identical results across architectures.\n'], [new vscode.Position(19, 6), 'func Println(a ...interface{}) (n int, err error)', printlnDoc], [new vscode.Position(27, 14), 'type ABC struct {\n a int\n b int\n c int\n}', 'ABC is a struct, you coudn\'t use Goto Definition or Hover info on this before\nNow you can due to gogetdoc and go doc\n'], - [new vscode.Position(28, 6), 'func CIDRMask(ones, bits int) IPMask', 'CIDRMask returns an IPMask consisting of `ones\' 1 bits\nfollowed by 0s up to a total length of `bits\' bits.\nFor a mask of this form, CIDRMask is the inverse of IPMask.Size.\n'] + [new vscode.Position(28, 6), 'func IPv4Mask(a, b, c, d byte) IPMask', 'IPv4Mask returns the IP mask (in 4-byte form) of the\nIPv4 mask a.b.c.d.\n'] ]; const config = Object.create(vscode.workspace.getConfiguration('go'), { 'docsTool': { value: 'gogetdoc' }