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

Commit

Permalink
Make linter tests more lax (#1558)
Browse files Browse the repository at this point in the history
  • Loading branch information
lggomez authored and ramya-rao-a committed Mar 6, 2018
1 parent 810791e commit 64104a1
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,19 @@ It returns the number of bytes written and any write error encountered.
}
return check(vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config).then(diagnostics => {
let sortedDiagnostics = diagnostics.sort((a, b) => a.line - b.line);
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
assert.equal(sortedDiagnostics.length > 0, true, `Failed to get linter results`);
let matchCount = 0;
for (let i in expected) {
if (expected[i].line) {
assert(sortedDiagnostics[i]);
assert.equal(sortedDiagnostics[i].line, expected[i].line);
};
assert.equal(sortedDiagnostics[i].severity, expected[i].severity);
assert.equal(sortedDiagnostics[i].msg, expected[i].msg);
for (let j in sortedDiagnostics) {
if (expected[i].line
&& (expected[i].line === sortedDiagnostics[j].line)
&& (expected[i].severity === sortedDiagnostics[j].severity)
&& (expected[i].msg === sortedDiagnostics[j].msg)) {
matchCount++;
}
}
}
assert.equal(matchCount >= expected.length, true, `Failed to match expected errors`);
});
}).then(() => done(), done);
});
Expand Down Expand Up @@ -395,13 +399,18 @@ It returns the number of bytes written and any write error encountered.
return 0;
});

assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);

assert.equal(sortedDiagnostics.length > 0, true, `Failed to get linter results`);
let matchCount = 0;
for (let i in expected) {
assert.equal(sortedDiagnostics[i].line, expected[i].line, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
assert.equal(sortedDiagnostics[i].severity, expected[i].severity, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
assert.equal(sortedDiagnostics[i].msg, expected[i].msg, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
for (let j in sortedDiagnostics) {
if ((expected[i].line === sortedDiagnostics[j].line)
&& (expected[i].severity === sortedDiagnostics[j].severity)
&& (expected[i].msg === sortedDiagnostics[j].msg)) {
matchCount++;
}
}
}
assert.equal(matchCount >= expected.length, true, `Failed to match expected errors`);

return Promise.resolve();
});
Expand Down

0 comments on commit 64104a1

Please # to comment.