Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add gometalinter test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sijad committed May 9, 2016
1 parent 467ab49 commit 32c4e3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ install:
- go get -u -v github.com/lukehoban/go-outline
- go get -u -v sourcegraph.com/sqs/goreturns
- go get -u -v golang.org/x/tools/cmd/gorename
- go get -u -v github.com/alecthomas/gometalinter
- gometalinter --install --update

script:
- npm run lint
Expand Down
31 changes: 31 additions & 0 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,35 @@ suite('Go Extension Tests', () => {
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
}).then(() => done(), done);
});

test('Gometalinter error checking', (done) => {
let config = vscode.workspace.getConfiguration('go');
config['lintTool'] = 'gometalinter';
let expected = [
{ line: 7, severity: 'warning', msg: 'Print2 is unused (deadcode)' },
{ line: 7, severity: 'warning', msg: 'exported function Print2 should have comment or be unexported (golint)' },
{ line: 10, severity: 'warning', msg: 'main2 is unused (deadcode)' },
{ line: 11, severity: 'warning', msg: 'undeclared name: prin (aligncheck)' },
{ line: 11, severity: 'warning', msg: 'undeclared name: prin (gotype)' },
{ line: 11, severity: 'warning', msg: 'undeclared name: prin (interfacer)' },
{ line: 11, severity: 'warning', msg: 'undeclared name: prin (unconvert)' },
{ line: 11, severity: 'error', msg: 'undefined: prin' },
{ line: 11, severity: 'warning', msg: 'unused struct field undeclared name: prin (structcheck)' },
];
check(path.join(fixturePath, 'errors.go'), config).then(diagnostics => {
let sortedDiagnostics = diagnostics.sort((a, b) => {
if ( a.msg < b.msg )
return -1;
if ( a.msg > b.msg )
return 1;
return 0;
});
for (let i in expected) {
assert.equal(sortedDiagnostics[i].line, expected[i].line);
assert.equal(sortedDiagnostics[i].severity, expected[i].severity);
assert.equal(sortedDiagnostics[i].msg, expected[i].msg);
}
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
}).then(() => done(), done);
});
});

0 comments on commit 32c4e3e

Please sign in to comment.