Skip to content

Commit

Permalink
Merge pull request #470 from stefan-toubia/wip/test-runner-message
Browse files Browse the repository at this point in the history
Add test message to test runner
  • Loading branch information
PEZ authored Nov 14, 2019
2 parents f719a60 + 85f26c1 commit c98baf3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Changes to Calva.

## [Unreleased]
- [Add test message to test runner](https://github.com/BetterThanTomorrow/calva/issues/425)
- [Fix: Lexing regex literal tokenisation](https://github.com/BetterThanTomorrow/calva/issues/463)
- [paredit.deleteBackward sets cursor position wrong when deleting a line. ](https://github.com/BetterThanTomorrow/calva/issues/458)
- [Calva Highlight sometimes incorrectly recognises form as a `comment` form](https://github.com/BetterThanTomorrow/calva/issues/403)
Expand Down
14 changes: 11 additions & 3 deletions src/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ function reportTests(results, errorStr, log = true) {
let resultSet = result.results[ns];
for (const test in resultSet) {
for (const a of resultSet[test]) {
const resultMessage = (resultItem) => {
let msg = [];
if(!_.isEmpty(resultItem.context) && resultItem.context !== "false")
msg.push(resultItem.context);
if(resultItem.message)
msg.push(resultItem.message);
return `${msg.join(": ")}${(msg.length > 0 ? "\n" : "")}`;
}
if (a.type == "error" && log)
chan.appendLine(`ERROR in: ${ns}: ${a.file}, line ${a.line}: ${test}: ${(a.context || "")}:\n error: ${a.error} + "\n expected: ${a.expected}`);
chan.appendLine(`ERROR in ${ns}/${test} (line ${a.line}):\n${resultMessage(a)} error: ${a.error} (${a.file})\nexpected: ${a.expected}`);
if (a.type == "fail") {
let msg = `failure in test: ${test} context: ${a.context}, expected ${a.expected}, got: ${a.actual}`,
err = new vscode.Diagnostic(new vscode.Range(a.line - 1, 0, a.line - 1, 1000), msg, vscode.DiagnosticSeverity.Error);
if (!diagnostics[a.file])
diagnostics[a.file] = [];
diagnostics[a.file].push(err);
if (log)
chan.appendLine(`FAIL in: ${a.file}: ${a.line}: ${test}: ${(a.context || "")}:\n expected: ${a.expected}\n actual: ${a.actual}`);
chan.appendLine(`FAIL in ${ns}/${test} (${a.file}:${a.line}):\n${resultMessage(a)}expected: ${a.expected} actual: ${a.actual}`);
}
}
}
Expand Down Expand Up @@ -160,4 +168,4 @@ export default {
runAllTestsCommand,
rerunTestsCommand,
runTestUnderCursorCommand
};
};

0 comments on commit c98baf3

Please sign in to comment.