Skip to content

Commit 669262e

Browse files
committed
fix: use known RemoteTestRunner frame prefixes
1 parent 03259d9 commit 669262e

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@ import { IRunTestContext, TestKind, TestLevel, TestResultState } from '../../jav
1313

1414
export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
1515

16-
private static readonly CONTROL_FRAME_PREFIX: RegExp = /^%[A-Z]+(?:\d+)?(?:\s|,|;)/;
17-
private static readonly NUMERIC_CONTROL_FRAME: RegExp = /^%[A-Z]+\d+$/;
16+
private static readonly CONTROL_MESSAGE_PREFIXES: string[] = [
17+
'%TSTTREE',
18+
'%TESTS',
19+
'%TESTE',
20+
'%FAILED',
21+
'%ERROR',
22+
'%EXPECTS',
23+
'%EXPECTE',
24+
'%ACTUALS',
25+
'%ACTUALE',
26+
'%TRACES',
27+
'%TRACEE',
28+
'%TESTC',
29+
'%RUNTIME',
30+
'%MENTER',
31+
'%MEXIT',
32+
];
1833

1934
private testOutputMapping: Map<string, ITestInfo> = new Map();
2035
private triggeredTestsMapping: Map<string, TestItem> = new Map();
@@ -71,25 +86,11 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
7186

7287
/**
7388
* Whether the given line is an Eclipse RemoteTestRunner control message.
74-
* Control messages start with '%' followed by an upper-case message id,
75-
* an optional index, and either a protocol separator (whitespace, comma, or semicolon)
76-
* or the end of the line for numeric-suffixed frames such as "%RUNTIME15".
77-
* Some payload delimiters, such as "%TRACES", are bare control frames with no suffix.
78-
* This avoids dropping legitimate output such as "%OK".
89+
* Only known protocol frame prefixes are filtered so user output that merely starts
90+
* with '%' (for example, "%OK" or "%STATUS 200") remains visible.
7991
*/
8092
private isControlMessage(line: string): boolean {
81-
return JUnitRunnerResultAnalyzer.CONTROL_FRAME_PREFIX.test(line)
82-
|| JUnitRunnerResultAnalyzer.NUMERIC_CONTROL_FRAME.test(line)
83-
|| this.isBareControlMessage(line);
84-
}
85-
86-
private isBareControlMessage(line: string): boolean {
87-
return line === MessageId.ExpectStart
88-
|| line === MessageId.ExpectEnd
89-
|| line === MessageId.ActualStart
90-
|| line === MessageId.ActualEnd
91-
|| line === MessageId.TraceStart
92-
|| line === MessageId.TraceEnd;
93+
return JUnitRunnerResultAnalyzer.CONTROL_MESSAGE_PREFIXES.some((prefix: string) => line.startsWith(prefix));
9394
}
9495

9596
public processData(data: string): void {

test/suite/JUnitAnalyzer.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ at junit4.TestAnnotation.shouldFail(TestAnnotation.java:15)
101101
Hello from System.out
102102
%OK
103103
%ABC
104+
%STATUS 200
104105
%FAILED 1,shouldFail(junit4.TestAnnotation)
105106
%EXPECTS
106107
expected
@@ -150,6 +151,7 @@ at junit4.TestAnnotation.shouldFail(TestAnnotation.java:15)
150151
assert.ok(echoedLines.includes('Hello from System.out'), 'Program output was dropped');
151152
assert.ok(echoedLines.includes('%OK'), 'Percent-prefixed program output was dropped');
152153
assert.ok(echoedLines.includes('%ABC'), 'Percent-prefixed program output was dropped');
154+
assert.ok(echoedLines.includes('%STATUS 200'), 'Percent-prefixed program output was dropped');
153155
assert.ok(echoedLines.includes('java.lang.AssertionError'), 'Stack trace content was dropped');
154156
assert.ok(!echoedLines.includes(''), 'Trailing newline produced a blank output line');
155157
});

0 commit comments

Comments
 (0)