diff options
Diffstat (limited to 'tests/auto/tools')
7 files changed, 49 insertions, 47 deletions
diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index d2cb9f2435..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 ) @@ -160,6 +166,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(); @@ -175,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); @@ -192,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); @@ -222,21 +240,21 @@ 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 ) +bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail ) { QDir D; D.setCurrent( workPath ); - QString cmdline = makeCmd_; + QString cmdline = makeCmd_ + " " + makeArgs_; if ( cmdline.contains("nmake", Qt::CaseInsensitive) ) cmdline.append(" /NOLOGO"); 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 116e424551..8aed3a9987 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -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 ); @@ -65,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 @@ -76,13 +80,13 @@ public: void clearCommandOutput(); private: - bool runCommand( QString cmdLine ); + bool runCommand( QString cmdLine, bool expectFail = false ); + bool errorOut(); - QString makeCmd_; - QString qmakeCmd_; + QString makeCmd_, makeArgs_; + QString qmakeCmd_, qmakeArgs_; QStringList environment_; - // need to make this available somewhere QStringList testOutput_; }; diff --git a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro index 644a817a8e..e4f81e6e1e 100644 --- a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro +++ b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro @@ -1,9 +1,3 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp QWERTY_BUNDLE.version = Bogus.78 diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 43577b5122..442c9c767f 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -1,10 +1,5 @@ -TEMPLATE = app -TARGET = findDeps -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h \ object2.h \ object3.h \ diff --git a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro index 1469b4c5c3..a4a7dc987d 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = findMocs -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h SOURCES += main.cpp diff --git a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro index 7f22f437c2..13d4d6c4ad 100644 --- a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro +++ b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro @@ -6,7 +6,9 @@ SOURCES = main.cpp RCCINPUT = "rc folder/test.qrc" RCCOUTPUT = test.cpp -rcc_test.commands = rcc -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} +qtPrepareTool(QMAKE_RCC, rcc) + +rcc_test.commands = $$QMAKE_RCC -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} rcc_test.output = $$RCCOUTPUT rcc_test.input = RCCINPUT rcc_test.variable_out = SOURCES diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4da781f763..88ff10a764 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -57,7 +57,6 @@ public: public slots: void initTestCase(); void cleanupTestCase(); - void init(); void cleanup(); private slots: @@ -131,13 +130,10 @@ void tst_qmake::cleanupTestCase() { } -void tst_qmake::init() -{ - test_compiler.clearCommandOutput(); -} - void tst_qmake::cleanup() { + test_compiler.resetArguments(); + test_compiler.resetEnvironment(); test_compiler.clearCommandOutput(); } @@ -305,7 +301,6 @@ void tst_qmake::export_across_file_boundaries() test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - test_compiler.resetEnvironment(); } void tst_qmake::include_dir() @@ -448,31 +443,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(), true) ); 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 |