Skip to content

Commit

Permalink
Merge pull request #1449 from BetterThanTomorrow/1448-newlines-in-tes…
Browse files Browse the repository at this point in the history
…t-results

Fix extraneous newlines in test results
  • Loading branch information
PEZ authored Dec 29, 2021
2 parents 29c6da4 + c3446be commit 509f323
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changes to Calva.
## [Unreleased]
- [Prevent warning during deps.edn jack-in](https://github.com/BetterThanTomorrow/calva/issues/1355)
- Fix: [Connecting to an out-of-process nREPL server and a merged Figwheel-main build](https://github.com/BetterThanTomorrow/calva/issues/1386)
- Fix: [Empty lines in output.calva-repl when running tests](https://github.com/BetterThanTomorrow/calva/issues/1448)

## [2.0.231] - 2021-12-14
- Fix: [Calva randomly edits file while in Live Share](https://github.com/BetterThanTomorrow/calva/issues/1434)
Expand Down
2 changes: 1 addition & 1 deletion src/extension-test/unit/test-runner-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('test result processing', () => {
index: 0,
var: 'test',
message: ''
})).toBe('');
})).toBe(null);

expect(cider.detailedMessage({
type: 'fail',
Expand Down
20 changes: 10 additions & 10 deletions src/nrepl/cider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ export function totalSummary(summaries: TestSummary[]): TestSummary {
// The message contains "comment" lines that are prepended with ;
// and "data" lines that should be printed verbatim into the REPL.
export function detailedMessage(result: TestResult): string {
const msg = [];
const messages = [];
const message = resultMessage(result);
if (result.type === "error") {
msg.push(`; ERROR in ${result.ns}/${result.var} (line ${result.line}):`)
messages.push(`; ERROR in ${result.ns}/${result.var} (line ${result.line}):`)
if (message) {
msg.push(`; ${message}`);
messages.push(`; ${message}`);
}
msg.push(`; error: ${result.error} (${result.file})`);
msg.push("; expected:");
msg.push(result.expected);
messages.push(`; error: ${result.error} (${result.file})`);
messages.push("; expected:");
messages.push(result.expected);
} else if (result.type === 'fail') {
msg.push(`; FAIL in ${result.ns}/${result.var} (${result.file}:${result.line}):`);
messages.push(`; FAIL in ${result.ns}/${result.var} (${result.file}:${result.line}):`);
if (message) {
msg.push(`; ${message}`);
messages.push(`; ${message}`);
}
msg.push(`; expected:\n${result.expected}\n; actual:\n${result.actual}`);
messages.push(`; expected:\n${result.expected}\n; actual:\n${result.actual}`);
}
return msg.join("\n");
return messages.length > 0 ? messages.join("\n") : null;
}

// Return a short message that can be shown to user as a Diagnostic.
Expand Down
8 changes: 4 additions & 4 deletions src/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function reportTests(results: cider.TestResults[]) {
let resultSet = result.results[ns];
for (const test in resultSet) {
for (const a of resultSet[test]) {

cider.cleanUpWhiteSpace(a);

outputWindow.append(cider.detailedMessage(a));

const messages = cider.detailedMessage(a);
if (messages) {
outputWindow.append(messages);
}
if (a.type === "fail") {
recordDiagnostic(a);
}
Expand Down
4 changes: 4 additions & 0 deletions test-data/projects/pirate-lang/src/pez/pirate_lang.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
:vowels "aeiou"
:pirate-char "o"})

(def swedish-o {:alphabet "abcdefghijklmnopqrstuvwxyz"
:vowels "aeiouåäö"
:pirate-char "o"})

(defn- configure
[{:keys [alphabet vowels pirate-char]}]
(let [alphabet (set (seq (string/upper-case alphabet)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
(ns pez.pirate-talk-test
(ns pez.pirate-lang-test
(:require [clojure.test :refer [deftest is testing]]
[pez.pirate-talk :as sut]))
[pez.pirate-lang :as sut]))

(def swedish-o {:alphabet "abcdefghijklmnopqrstuvwxyzåäö"
:vowels "aeiouåäö"
:pirate-char "o"})
(deftest a-test
(testing "Speak rövarspråk"
(is (= "HoHaror dodu hohörortot totalolasos omom rorövovarorsospoproråkoketot?"
(sut/to-pirate-talk "Har du hört talas om rövarspråket?" sut/swedish-o))))
(testing "Swedish"
(is (= "HoHaror dodu hohörortot totalolasos omom rorövovarorsospoproråkoketot?"
(sut/to-pirate-talk "Har du hört talas om rövarspråket?" sut/swedish-o)))))
(testing "Hear rövarspråk"
(is (= "Har du hört talas om rövarspråket?"
(sut/from-pirate-talk "HoHaror dodu hohörortot totalolasos omom rorövovarorsospoproråkoketot?" sut/swedish-o)))))

0 comments on commit 509f323

Please sign in to comment.