TestCompiler: split commands from arguments
this allows us to temporarily set some extra args without (incorrectly) instantiating a second TestCompiler (and on the way relying on $PATH for finding qmake). Change-Id: Icce5bf7314148ddbe705606f77a26e3362b31f67 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
parent
091dd54a6c
commit
edde615209
@ -160,6 +160,18 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd )
|
||||
qmakeCmd_ = qmakeCmd;
|
||||
}
|
||||
|
||||
void TestCompiler::resetArguments()
|
||||
{
|
||||
makeArgs_.clear();
|
||||
qmakeArgs_.clear();
|
||||
}
|
||||
|
||||
void TestCompiler::setArguments( QString makeArgs, QString qmakeArgs )
|
||||
{
|
||||
makeArgs_ = makeArgs;
|
||||
qmakeArgs_ = qmakeArgs;
|
||||
}
|
||||
|
||||
void TestCompiler::resetEnvironment()
|
||||
{
|
||||
environment_.clear();
|
||||
@ -222,7 +234,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const
|
||||
makeFile += "Makefile";
|
||||
|
||||
// Now start qmake and generate the makefile
|
||||
return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile );
|
||||
return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile );
|
||||
}
|
||||
|
||||
bool TestCompiler::make( const QString &workPath, const QString &target )
|
||||
@ -230,7 +242,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target )
|
||||
QDir D;
|
||||
D.setCurrent( workPath );
|
||||
|
||||
QString cmdline = makeCmd_;
|
||||
QString cmdline = makeCmd_ + " " + makeArgs_;
|
||||
if ( cmdline.contains("nmake", Qt::CaseInsensitive) )
|
||||
cmdline.append(" /NOLOGO");
|
||||
if ( !target.isEmpty() )
|
||||
|
@ -55,6 +55,10 @@ public:
|
||||
virtual ~TestCompiler();
|
||||
|
||||
void setBaseCommands( QString makeCmd, QString qmakeCmd );
|
||||
|
||||
void resetArguments();
|
||||
void setArguments( QString makeArgs, QString qmakeArgs );
|
||||
|
||||
void resetEnvironment();
|
||||
void addToEnvironment( QString varAssignment );
|
||||
|
||||
@ -78,8 +82,8 @@ public:
|
||||
private:
|
||||
bool runCommand( QString cmdLine );
|
||||
|
||||
QString makeCmd_;
|
||||
QString qmakeCmd_;
|
||||
QString makeCmd_, makeArgs_;
|
||||
QString qmakeCmd_, qmakeArgs_;
|
||||
QStringList environment_;
|
||||
|
||||
// need to make this available somewhere
|
||||
|
@ -138,6 +138,7 @@ void tst_qmake::init()
|
||||
|
||||
void tst_qmake::cleanup()
|
||||
{
|
||||
test_compiler.resetArguments();
|
||||
test_compiler.clearCommandOutput();
|
||||
}
|
||||
|
||||
@ -448,31 +449,30 @@ void tst_qmake::bundle_spaces()
|
||||
{
|
||||
QString workDir = base_path + "/testdata/bundle-spaces";
|
||||
|
||||
// We set up alternate commands here, to make sure we're testing Mac
|
||||
// We set up alternate arguments here, to make sure we're testing Mac
|
||||
// Bundles and since this might be the wrong output we rely on dry-running
|
||||
// make (-n).
|
||||
|
||||
TestCompiler local_tc;
|
||||
local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++");
|
||||
test_compiler.setArguments("-n", "-spec macx-g++");
|
||||
|
||||
QVERIFY( local_tc.qmake(workDir, "bundle-spaces") );
|
||||
QVERIFY( test_compiler.qmake(workDir, "bundle-spaces") );
|
||||
|
||||
TempFile non_existing_file(workDir + "/non-existing file");
|
||||
QVERIFY( !non_existing_file.exists() );
|
||||
|
||||
// Make fails: no rule to make "non-existing file"
|
||||
QVERIFY( !local_tc.make(workDir) );
|
||||
QVERIFY( !test_compiler.make(workDir, QString()) );
|
||||
|
||||
QVERIFY( non_existing_file.open(QIODevice::WriteOnly) );
|
||||
QVERIFY( non_existing_file.exists() );
|
||||
|
||||
// Aha!
|
||||
QVERIFY( local_tc.make(workDir) );
|
||||
QVERIFY( test_compiler.make(workDir) );
|
||||
|
||||
// Cleanup
|
||||
QVERIFY( non_existing_file.remove() );
|
||||
QVERIFY( !non_existing_file.exists() );
|
||||
QVERIFY( local_tc.removeMakefile(workDir) );
|
||||
QVERIFY( test_compiler.removeMakefile(workDir) );
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user