From 85f26c16f771921fb441ae463b0c90772b4ac46d Mon Sep 17 00:00:00 2001 From: stefan toubia Date: Thu, 14 Nov 2019 12:36:58 -0800 Subject: [PATCH] Add test message to test runner --- CHANGELOG.md | 1 + src/testRunner.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caad86174..32bc92e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) ## [2.0.60] - 2019-11-11 diff --git a/src/testRunner.ts b/src/testRunner.ts index 3a0c40ad6..3ff8e8009 100644 --- a/src/testRunner.ts +++ b/src/testRunner.ts @@ -23,8 +23,16 @@ 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); @@ -32,7 +40,7 @@ function reportTests(results, errorStr, log = true) { 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}`); } } } @@ -160,4 +168,4 @@ export default { runAllTestsCommand, rerunTestsCommand, runTestUnderCursorCommand -}; \ No newline at end of file +};