{
}
-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);
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 )
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
- return false;
+ return errorOut();
}
D.setCurrent(workPath);
QDir D;
if (!D.exists(workPath)) {
testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
- return false;
+ return errorOut();
}
D.setCurrent(workPath);
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 );
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 )
// 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
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_;
};
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() );