diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-16 13:53:05 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-23 08:47:08 +0000 |
commit | 1c6e4fbd3211bc180b0de95d232226825bcb124d (patch) | |
tree | c9adce875a62a7fa980eb8a99231034585ae8fbf /src/plugins/projectexplorer/outputparser_test.cpp | |
parent | b7851eeb55fd284bd647b7042e7f94a1ea1d3490 (diff) |
Merge output formatters and output parsers
Now only one piece of code needs to be written to both linkify output in
an output pane and create tasks for it in the issues pane.
The calling sites are also simplified. For instance, until now, build
steps had to feed their output parsers manually and then push the
created tasks up the signal stack in parallel with the actual output,
which the build manager relied upon for cross-linking the output pane
content. Afterwards, the output would get forwarded to the formatter
(and parsed for ANSI escape codes a second time). In contrast, a build
step now just forwards the process output, and task parsing as well as
output formatting is done centrally further up the stack.
Concrete user-visible improvements so far:
- File paths in compiler/linker messages are clickable links now.
- QtTest applications now create clickable links also when run
as part of a build step, not just in the app output pane.
Task-number: QTCREATORBUG-22665
Change-Id: Ic9fb95b2d97f2520ab3ec653315e9219466ec08d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/outputparser_test.cpp')
-rw-r--r-- | src/plugins/projectexplorer/outputparser_test.cpp | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp index 8caec11242..8516a84de0 100644 --- a/src/plugins/projectexplorer/outputparser_test.cpp +++ b/src/plugins/projectexplorer/outputparser_test.cpp @@ -24,7 +24,9 @@ ****************************************************************************/ #include "outputparser_test.h" +#include "projectexplorer.h" #include "task.h" +#include "taskhub.h" #if defined(WITH_TESTS) @@ -41,11 +43,16 @@ static inline QByteArray msgFileComparisonFail(const Utils::FilePath &f1, const // test functions: OutputParserTester::OutputParserTester() { - connect(this, &IOutputParser::addTask, this, [this](const Task &t) { + connect(TaskHub::instance(), &TaskHub::taskAdded, this, [this](const Task &t) { m_receivedTasks.append(t); }); } +OutputParserTester::~OutputParserTester() +{ + TaskHub::instance()->disconnect(this); +} + void OutputParserTester::testParsing(const QString &lines, Channel inputChannel, Tasks tasks, @@ -60,9 +67,9 @@ void OutputParserTester::testParsing(const QString &lines, reset(); if (inputChannel == STDOUT) - handleStdout(lines + '\n'); + appendMessage(lines + '\n', Utils::StdOutFormat); else - handleStderr(lines + '\n'); + appendMessage(lines + '\n', Utils::StdErrFormat); flush(); // delete the parser(s) to test @@ -102,7 +109,7 @@ TestTerminator::TestTerminator(OutputParserTester *t) : m_tester(t) { } -OutputTaskParser::Status TestTerminator::handleLine(const QString &line, Utils::OutputFormat type) +Utils::OutputLineParser::Result TestTerminator::handleLine(const QString &line, Utils::OutputFormat type) { QTC_CHECK(line.endsWith('\n')); if (type == Utils::StdOutFormat) @@ -112,6 +119,64 @@ OutputTaskParser::Status TestTerminator::handleLine(const QString &line, Utils:: return Status::Done; } +void ProjectExplorerPlugin::testAnsiFilterOutputParser_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<OutputParserTester::Channel>("inputChannel"); + QTest::addColumn<QString>("childStdOutLines"); + QTest::addColumn<QString>("childStdErrLines"); + QTest::addColumn<QString>("outputLines"); + + QTest::newRow("pass-through stdout") + << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT + << QString::fromLatin1("Sometext\n") << QString(); + QTest::newRow("pass-through stderr") + << QString::fromLatin1("Sometext") << OutputParserTester::STDERR + << QString() << QString::fromLatin1("Sometext\n"); + + QString input = QString::fromLatin1("te") + QChar(27) + QString::fromLatin1("Nst"); + QTest::newRow("ANSI: ESC-N") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("^ignored") + QChar(27) + QLatin1String("\\st"); + QTest::newRow("ANSI: ESC-^ignoredESC-\\") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("]0;ignored") + QChar(7) + QLatin1String("st"); + QTest::newRow("ANSI: window title change") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("[Ast"); + QTest::newRow("ANSI: cursor up") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("[2Ast"); + QTest::newRow("ANSI: cursor up (with int parameter)") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("[2;3Hst"); + QTest::newRow("ANSI: position cursor") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); + input = QString::fromLatin1("te") + QChar(27) + QLatin1String("[31;1mst"); + QTest::newRow("ANSI: bold red") + << input << OutputParserTester::STDOUT + << QString::fromLatin1("test\n") << QString(); +} + +void ProjectExplorerPlugin::testAnsiFilterOutputParser() +{ + OutputParserTester testbench; + QFETCH(QString, input); + QFETCH(OutputParserTester::Channel, inputChannel); + QFETCH(QString, childStdOutLines); + QFETCH(QString, childStdErrLines); + + testbench.testParsing(input, inputChannel, + Tasks(), childStdOutLines, childStdErrLines, + QString()); +} + } // namespace ProjectExplorer #endif |