aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/outputparser_test.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2013-05-03 16:02:53 +0200
committerTobias Hunger <tobias.hunger@digia.com>2013-05-06 10:04:23 +0200
commit14763118a58bf526f873b6750c3785f8752e4d7e (patch)
tree7312632b55035129adf70fc87ebcb1b8d2583f04 /src/plugins/projectexplorer/outputparser_test.cpp
parentfa9d57fb689fc76416eaa4f1dadd89a83acdaa48 (diff)
Make test bench for IOutputParser tests more stable
Change-Id: I39a08912efdcf34ef680d508c41c4df9034125dc Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/projectexplorer/outputparser_test.cpp')
-rw-r--r--src/plugins/projectexplorer/outputparser_test.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp
index f9b2e29872..5bb324a1ec 100644
--- a/src/plugins/projectexplorer/outputparser_test.cpp
+++ b/src/plugins/projectexplorer/outputparser_test.cpp
@@ -34,18 +34,11 @@
#include <QtTest>
-using namespace ProjectExplorer;
+namespace ProjectExplorer {
OutputParserTester::OutputParserTester() :
- m_debug(false)
-{
-}
-
-OutputParserTester::~OutputParserTester()
-{
- if (childParser())
- childParser()->takeOutputParserChain();
-}
+ m_debug(false)
+{ }
// test methods:
void OutputParserTester::testParsing(const QString &lines,
@@ -65,6 +58,7 @@ void OutputParserTester::testParsing(const QString &lines,
else
childParser()->stdError(input + QLatin1Char('\n'));
}
+
// first disconnect ourselves from the end of the parser chain again
IOutputParser * parser = this;
while ( (parser = parser->childParser()) ) {
@@ -131,24 +125,11 @@ void OutputParserTester::setDebugEnabled(bool debug)
m_debug = debug;
}
-void OutputParserTester::stdOutput(const QString &line)
-{
- QVERIFY(line.endsWith(QLatin1Char('\n')));
- m_receivedStdOutChildLine.append(line);
-}
-
-void OutputParserTester::stdError(const QString &line)
-{
- QVERIFY(line.endsWith(QLatin1Char('\n')));
- m_receivedStdErrChildLine.append(line);
-}
-
void OutputParserTester::appendOutputParser(IOutputParser *parser)
{
Q_ASSERT(!childParser());
-
+ parser->appendOutputParser(new TestTerminator(this));
IOutputParser::appendOutputParser(parser);
- parser->appendOutputParser(this);
}
void OutputParserTester::outputAdded(const QString &line, ProjectExplorer::BuildStep::OutputFormat format)
@@ -172,4 +153,22 @@ void OutputParserTester::reset()
m_receivedOutput.clear();
}
+TestTerminator::TestTerminator(OutputParserTester *t) :
+ m_tester(t)
+{ }
+
+void TestTerminator::stdOutput(const QString &line)
+{
+ QVERIFY(line.endsWith(QLatin1Char('\n')));
+ m_tester->m_receivedStdOutChildLine.append(line);
+}
+
+void TestTerminator::stdError(const QString &line)
+{
+ QVERIFY(line.endsWith(QLatin1Char('\n')));
+ m_tester->m_receivedStdErrChildLine.append(line);
+}
+
+} // namespace ProjectExplorer
+
#endif