diff --git a/.vscode/settings.json b/.vscode/settings.json index 6a723cb9..2a112c09 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -112,16 +112,7 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, - "todo-tree.general.tags": [ - "BUG", - "HACK", - "FIXME", - "TODO", - "TODO:future", - "TODO:nice", - "TODO:release", - "XXX" - ], + "todo-tree.general.tags": ["BUG", "HACK", "FIXME", "TODO", "TODO:future", "TODO:nice", "TODO:release", "XXX"], "todo-tree.highlights.customHighlight": { "TODO:future": { "type": "none" @@ -136,5 +127,8 @@ "type": "tag", "background": "yellow" } + }, + "[xml]": { + "editor.defaultFormatter": "DotJoshJohnson.xml" } -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a788e4..f45fda6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [4.0.25] + +- fixed GoogleTest cout and cerr parsin [issue#329](https://github.com/matepek/vscode-catch2-test-adapter/issues/329) and [issue#323](https://github.com/matepek/vscode-catch2-test-adapter/issues/323). + ## [4.0.24] - 2022-02-01 ## Changed diff --git a/src/AbstractExecutable.ts b/src/AbstractExecutable.ts index bff349e8..48209152 100644 --- a/src/AbstractExecutable.ts +++ b/src/AbstractExecutable.ts @@ -821,7 +821,7 @@ export abstract class AbstractExecutable runPrefix + '> ' + x + '\r\n').join('')); + testRun.appendOutput(indented.map(x => runPrefix + x + '\r\n').join('')); testRun.appendOutput(runPrefix + '⬆ std::cerr\r\n'); } } diff --git a/src/ConfigOfExecGroup.ts b/src/ConfigOfExecGroup.ts index b8e5703e..d1e33ae0 100644 --- a/src/ConfigOfExecGroup.ts +++ b/src/ConfigOfExecGroup.ts @@ -229,7 +229,7 @@ export class ConfigOfExecGroup implements vscode.Disposable { private async _createSuiteByUri(filePath: string): Promise { const relPath = pathlib.relative(this._shared.workspaceFolder.uri.fsPath, filePath); - let varToValue: ResolveRuleAsync[] = []; + const varToValue: ResolveRuleAsync[] = []; const subPath = createPythonIndexerForPathVariable; @@ -242,7 +242,7 @@ export class ConfigOfExecGroup implements vscode.Disposable { const baseFilename = pathlib.basename(filename, extFilename); const relDirpath = pathlib.dirname(relPath); - varToValue = [ + varToValue.push( { resolve: '${filename}', rule: filename }, // redundant but might faster { resolve: '${relDirpath}', rule: relDirpath }, // redundant but might faster subFilename('filename', filename), @@ -253,7 +253,7 @@ export class ConfigOfExecGroup implements vscode.Disposable { { resolve: '${extFilename}', rule: extFilename }, { resolve: '${baseFilename}', rule: baseFilename }, ...this._shared.varToValue, - ]; + ); } catch (e) { this._shared.log.exceptionS(e); } diff --git a/src/framework/DOCExecutable.ts b/src/framework/DOCExecutable.ts index fa3ad164..8654d070 100644 --- a/src/framework/DOCExecutable.ts +++ b/src/framework/DOCExecutable.ts @@ -353,7 +353,7 @@ abstract class TagProcessorBase implements XmlTagProcessor { } else if (processor === null) { // known tag, do nothing } else { - this.builder.addOutputLine(1, '> ' + dataTrimmed); + this.builder.addOutputLine(1, dataTrimmed); } } diff --git a/src/framework/GoogleTestExecutable.ts b/src/framework/GoogleTestExecutable.ts index 12cd7c28..3b453811 100644 --- a/src/framework/GoogleTestExecutable.ts +++ b/src/framework/GoogleTestExecutable.ts @@ -232,39 +232,50 @@ export class GoogleTestExecutable extends AbstractExecutable { const data = { lastBuilder: undefined as TestResultBuilder | undefined }; // we dont need this now: const rngSeed: number | undefined = typeof this._shared.rngSeed === 'number' ? this._shared.rngSeed : undefined; - const parser = new TextStreamParser(this.shared.log, { - async online(line: string): Promise { - const beginMatch = testBeginRe.exec(line); - if (beginMatch) { - const testNameAsId = beginMatch[1]; - const testName = beginMatch[3]; - const suiteName = beginMatch[2]; - let test = executable._getTest(testNameAsId); - if (!test) { - log.info('TestCase not found in children', testNameAsId); - test = await executable._createAndAddTest(testName, suiteName, undefined, undefined, undefined, undefined); - unexpectedTests.push(test); - } else { - expectedToRunAndFoundTests.push(test); - } - data.lastBuilder = new TestResultBuilder(test, testRun, runInfo.runPrefix, false); - return new TestCaseProcessor(executable.shared, testEndRe(test.id), data.lastBuilder); - } else if (line.startsWith('[----------] Global test environment tear-down')) { - return new NoOpLineProcessor(); - } else { - if ( - line === '' || - ['Running main()', 'Note: Google Test filter =', '[==========]', '[----------]'].some(x => - line.startsWith(x), - ) - ) { - //skip + const parser = new TextStreamParser( + this.shared.log, + { + async online(line: string): Promise { + const beginMatch = testBeginRe.exec(line); + if (beginMatch) { + const testNameAsId = beginMatch[1]; + const testName = beginMatch[3]; + const suiteName = beginMatch[2]; + let test = executable._getTest(testNameAsId); + if (!test) { + log.info('TestCase not found in children', testNameAsId); + test = await executable._createAndAddTest( + testName, + suiteName, + undefined, + undefined, + undefined, + undefined, + ); + unexpectedTests.push(test); + } else { + expectedToRunAndFoundTests.push(test); + } + data.lastBuilder = new TestResultBuilder(test, testRun, runInfo.runPrefix, false); + return new TestCaseProcessor(executable.shared, testEndRe(test.id), data.lastBuilder); + } else if (line.startsWith('[----------] Global test environment tear-down')) { + return new NoOpLineProcessor(); } else { - testRun.appendOutput(runInfo.runPrefix + line + '\r\n'); + if ( + line === '' || + ['Running main()', 'Note: Google Test filter =', '[==========]', '[----------]'].some(x => + line.startsWith(x), + ) + ) { + //skip + } else { + testRun.appendOutput(runInfo.runPrefix + line + '\r\n'); + } } - } + }, }, - }); + false, + ); await pipeProcess2Parser(runInfo, parser, (data: string) => executable.processStdErr(testRun, runInfo.runPrefix, data), @@ -444,6 +455,8 @@ class TestCaseProcessor implements LineProcessor { break; } } + + this.testCaseShared.builder.addOutputLine(1, line); } } diff --git a/src/util/TextStreamParser.ts b/src/util/TextStreamParser.ts index b5e13233..aadaeaec 100644 --- a/src/util/TextStreamParser.ts +++ b/src/util/TextStreamParser.ts @@ -3,7 +3,11 @@ import { debugBreak } from './DevelopmentHelper'; import { ParserInterface } from './ParserInterface'; export class TextStreamParser implements ParserInterface { - constructor(private readonly log: LoggerWrapper, rootProcessor: RootLineProcessor) { + constructor( + private readonly log: LoggerWrapper, + rootProcessor: RootLineProcessor, + private readonly handleStdErr = true, + ) { this.topProcessor = rootProcessor; this.alwaysonlineCb = rootProcessor.alwaysonline; } @@ -52,9 +56,9 @@ export class TextStreamParser implements ParserInterface { } } - writeStdErr(data: string): Promise { - this.write(data); - return Promise.resolve(true); + writeStdErr(data: string): Promise { + if (this.handleStdErr) this.write(data); + return Promise.resolve(this.handleStdErr); } private _process(): void { diff --git a/test/cpp/gtest/gtest1.cpp b/test/cpp/gtest/gtest1.cpp index 34528dfb..a4585b63 100644 --- a/test/cpp/gtest/gtest1.cpp +++ b/test/cpp/gtest/gtest1.cpp @@ -143,3 +143,9 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } + +TEST(Std, NoOutput) +{ + std::cout << "cout\n"; // (1) + std::cerr << "cerr\n"; // (2) +} \ No newline at end of file