summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-02-23 15:38:30 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-27 20:52:45 +0100
commitfd1d98b6af09d7cff73c3316097277131d82cd38 (patch)
tree4940bb66ab56b88cc8be845e377f9185cce6ec55 /tests
parentedde6152094702aa4c3415920d2c962009619743 (diff)
make qmake test suite a tad more verbose on failure
automatically dump the collected output on non-expected return code Change-Id: Ifda7287869f329c5a6714e6f21aa9c3991e9ee4e Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/qmake/testcompiler.cpp24
-rw-r--r--tests/auto/tools/qmake/testcompiler.h6
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp2
3 files changed, 19 insertions, 13 deletions
diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp
index 8864d4d435..97c640b28f 100644
--- a/tests/auto/tools/qmake/testcompiler.cpp
+++ b/tests/auto/tools/qmake/testcompiler.cpp
@@ -126,7 +126,13 @@ TestCompiler::~TestCompiler()
{
}
-bool TestCompiler::runCommand( QString cmdline )
+bool TestCompiler::errorOut()
+{
+ qDebug(qPrintable(testOutput_.join("\n")));
+ return false;
+}
+
+bool TestCompiler::runCommand( QString cmdline, bool expectFail )
{
testOutput_.append("Running command: " + cmdline);
@@ -137,21 +143,21 @@ bool TestCompiler::runCommand( QString cmdline )
child.start(cmdline);
if (!child.waitForStarted(-1)) {
testOutput_.append( "Unable to start child process." );
- return false;
+ return errorOut();
}
- bool failed = false;
child.setReadChannel(QProcess::StandardError);
child.waitForFinished(-1);
+ bool ok = child.exitStatus() == QProcess::NormalExit && (expectFail ^ (child.exitCode() == 0));
foreach (const QByteArray &output, child.readAllStandardError().split('\n')) {
testOutput_.append(QString::fromLocal8Bit(output));
if (output.startsWith("Project MESSAGE: FAILED"))
- failed = true;
+ ok = false;
}
- return !failed && child.exitStatus() == QProcess::NormalExit && child.exitCode() == 0;
+ return ok ? true : errorOut();
}
void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd )
@@ -187,7 +193,7 @@ bool TestCompiler::makeClean( const QString &workPath )
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
- return false;
+ return errorOut();
}
D.setCurrent(workPath);
@@ -204,7 +210,7 @@ bool TestCompiler::makeDistClean( const QString &workPath )
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
- return false;
+ return errorOut();
}
D.setCurrent(workPath);
@@ -237,7 +243,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const
return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile );
}
-bool TestCompiler::make( const QString &workPath, const QString &target )
+bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
{
QDir D;
D.setCurrent( workPath );
@@ -248,7 +254,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target )
if ( !target.isEmpty() )
cmdline += " " + target;
- return runCommand( cmdline );
+ return runCommand( cmdline, expectFail );
}
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )
diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h
index c438b52db2..8aed3a9987 100644
--- a/tests/auto/tools/qmake/testcompiler.h
+++ b/tests/auto/tools/qmake/testcompiler.h
@@ -69,7 +69,7 @@ public:
// executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null
bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() );
// executes a make in the specified workPath, with an optional target (eg. install)
- bool make( const QString &workPath, const QString &target = QString() );
+ bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
// checks if the executable exists in destDir
bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version );
// removes the makefile
@@ -80,13 +80,13 @@ public:
void clearCommandOutput();
private:
- bool runCommand( QString cmdLine );
+ bool runCommand( QString cmdLine, bool expectFail = false );
+ bool errorOut();
QString makeCmd_, makeArgs_;
QString qmakeCmd_, qmakeArgs_;
QStringList environment_;
- // need to make this available somewhere
QStringList testOutput_;
};
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index c01900c26e..f6d88ffce3 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -461,7 +461,7 @@ void tst_qmake::bundle_spaces()
QVERIFY( !non_existing_file.exists() );
// Make fails: no rule to make "non-existing file"
- QVERIFY( !test_compiler.make(workDir, QString()) );
+ QVERIFY( test_compiler.make(workDir, QString(), true) );
QVERIFY( non_existing_file.open(QIODevice::WriteOnly) );
QVERIFY( non_existing_file.exists() );