make test support qmake path with spaces

Change-Id: I66d8b3cc742c44d02c224bbfc4086500af0d5f4a
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Oswald Buddenhagen 2014-11-27 14:12:52 +01:00
parent 8d71fcabb1
commit ed3aca119f
3 changed files with 30 additions and 19 deletions

View File

@ -146,14 +146,22 @@ static inline QStringList systemEnvironment()
return result;
}
bool TestCompiler::runCommand( QString cmdline, bool expectFail )
bool TestCompiler::runCommand(const QString &cmd, const QStringList &args, bool expectFail)
{
testOutput_.append("Running command: " + cmdline);
QString dbg = cmd;
if (dbg.contains(' '))
dbg.prepend('"').append('"');
foreach (QString arg, args) {
if (arg.contains(' '))
arg.prepend('"').append('"');
dbg.append(' ').append(arg);
}
testOutput_.append("Running command: " + dbg);
QProcess child;
child.setEnvironment(systemEnvironment() + environment_);
child.start(cmdline);
child.start(cmd, args);
if (!child.waitForStarted(-1)) {
testOutput_.append( "Unable to start child process." );
return errorOut();
@ -185,7 +193,7 @@ void TestCompiler::resetArguments()
qmakeArgs_.clear();
}
void TestCompiler::setArguments( QString makeArgs, QString qmakeArgs )
void TestCompiler::setArguments(const QStringList &makeArgs, const QStringList &qmakeArgs)
{
makeArgs_ = makeArgs;
qmakeArgs_ = qmakeArgs;
@ -213,7 +221,7 @@ bool TestCompiler::makeClean( const QString &workPath )
QFileInfo Fi( workPath + "/Makefile");
if (Fi.exists())
// Run make clean
return runCommand( makeCmd_ + " clean" );
return runCommand(makeCmd_, QStringList() << "clean");
return true;
}
@ -230,7 +238,7 @@ bool TestCompiler::makeDistClean( const QString &workPath )
QFileInfo Fi( workPath + "/Makefile");
if (Fi.exists())
// Run make distclean
return runCommand( makeCmd_ + " distclean" );
return runCommand(makeCmd_, QStringList() << "distclean");
return true;
@ -249,7 +257,7 @@ bool TestCompiler::qmakeProject( const QString &workDir, const QString &proName
if (!projectFile.endsWith(".pro"))
projectFile += ".pro";
return runCommand(qmakeCmd_ + " -project -o " + projectFile + " DESTDIR=./");
return runCommand(qmakeCmd_, QStringList() << "-project" << "-o" << projectFile << "DESTDIR=./");
}
bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir )
@ -269,7 +277,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const
makeFile += "Makefile";
// Now start qmake and generate the makefile
return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile );
return runCommand(qmakeCmd_, QStringList(qmakeArgs_) << projectFile << "-o" << makeFile);
}
bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
@ -277,13 +285,13 @@ bool TestCompiler::make( const QString &workPath, const QString &target, bool ex
QDir D;
D.setCurrent( workPath );
QString cmdline = makeCmd_ + " " + makeArgs_;
if ( cmdline.contains("nmake", Qt::CaseInsensitive) )
cmdline.append(" /NOLOGO");
if ( !target.isEmpty() )
cmdline += " " + target;
QStringList args = makeArgs_;
if (makeCmd_.contains("nmake", Qt::CaseInsensitive))
args << "/NOLOGO";
if (!target.isEmpty())
args << target;
return runCommand( cmdline, expectFail );
return runCommand(makeCmd_, args, expectFail);
}
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )

View File

@ -49,7 +49,7 @@ public:
void setBaseCommands( QString makeCmd, QString qmakeCmd );
void resetArguments();
void setArguments( QString makeArgs, QString qmakeArgs );
void setArguments(const QStringList &makeArgs, const QStringList &qmakeArgs);
void resetEnvironment();
void addToEnvironment( QString varAssignment );
@ -78,11 +78,13 @@ public:
void clearCommandOutput();
private:
bool runCommand( QString cmdLine, bool expectFail = false );
bool runCommand(const QString &cmd, const QStringList &args, bool expectFail = false);
bool errorOut();
QString makeCmd_, makeArgs_;
QString qmakeCmd_, qmakeArgs_;
QString makeCmd_;
QStringList makeArgs_;
QString qmakeCmd_;
QStringList qmakeArgs_;
QStringList environment_;
QStringList testOutput_;

View File

@ -461,7 +461,8 @@ void tst_qmake::bundle_spaces()
// Bundles and since this might be the wrong output we rely on dry-running
// make (-n).
test_compiler.setArguments("-n", "-spec macx-clang");
test_compiler.setArguments(QStringList() << "-n",
QStringList() << "-spec" << "macx-clang");
QVERIFY( test_compiler.qmake(workDir, "bundle-spaces") );