Skip to content

Commit 03259d9

Browse files
committed
fix: skip trailing empty runner output
1 parent 959ce79 commit 03259d9

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
5454

5555
public analyzeData(data: string): void {
5656
const lines: string[] = data.split(/\r?\n/);
57-
for (const line of lines) {
57+
const endsWithNewLine: boolean = /\r?\n$/.test(data);
58+
for (let i: number = 0; i < lines.length; i++) {
59+
const line: string = lines[i];
60+
if (i === lines.length - 1 && endsWithNewLine && line === '') {
61+
continue;
62+
}
5863
this.processData(line);
5964
// Hide Eclipse RemoteTestRunner protocol frames already consumed by processData().
6065
// Forward everything else, including stdout/stderr and trace payload lines.

test/suite/JUnitAnalyzer.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ at org.junit.Assert.assertTrue(Assert.java:53)
7070
at junit4.TestAnnotation.shouldFail(TestAnnotation.java:15)
7171
%TRACEE
7272
%TESTE 1,shouldFail(junit4.TestAnnotation)
73-
%RUNTIME20`;
73+
%RUNTIME20
74+
`;
7475
const runnerContext: IRunTestContext = {
7576
isDebug: false,
7677
kind: TestKind.JUnit,
@@ -150,6 +151,7 @@ at junit4.TestAnnotation.shouldFail(TestAnnotation.java:15)
150151
assert.ok(echoedLines.includes('%OK'), 'Percent-prefixed program output was dropped');
151152
assert.ok(echoedLines.includes('%ABC'), 'Percent-prefixed program output was dropped');
152153
assert.ok(echoedLines.includes('java.lang.AssertionError'), 'Stack trace content was dropped');
154+
assert.ok(!echoedLines.includes(''), 'Trailing newline produced a blank output line');
153155
});
154156

155157
test("test stacktrace should be simplified", () => {

0 commit comments

Comments
 (0)