summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/qmake/qmake.pro2
-rw-r--r--tests/auto/qmake/testcompiler.cpp205
-rw-r--r--tests/auto/qmake/testcompiler.h29
-rw-r--r--tests/auto/qmake/tst_qmake.cpp16
4 files changed, 67 insertions, 185 deletions
diff --git a/tests/auto/qmake/qmake.pro b/tests/auto/qmake/qmake.pro
index 59cc2be..8cae6be 100644
--- a/tests/auto/qmake/qmake.pro
+++ b/tests/auto/qmake/qmake.pro
@@ -2,8 +2,6 @@ load(qttest_p4)
HEADERS += testcompiler.h
SOURCES += tst_qmake.cpp testcompiler.cpp
-contains(QT_CONFIG, qt3support): QT += qt3support
-
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp
index bfc8905..c25b851 100644
--- a/tests/auto/qmake/testcompiler.cpp
+++ b/tests/auto/qmake/testcompiler.cpp
@@ -44,9 +44,7 @@
#include <stdlib.h>
#include <qapplication.h>
-#ifdef QT3_SUPPORT
-
-#include <q3process.h>
+#include <qprocess.h>
#include <qtimer.h>
#ifdef Q_OS_WIN32
# include <windows.h>
@@ -59,6 +57,7 @@
QString targetName( BuildType buildMode, const QString& target, const QString& version )
{
+ Q_UNUSED(version);
QString targetName = target;
#if defined (Q_OS_WIN32)
@@ -135,120 +134,49 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v
TestCompiler::TestCompiler()
{
- exit_ok = FALSE;
- childProc = 0;
- setBaseCommands( "", "", FALSE );
+ setBaseCommands( "", "" );
}
TestCompiler::~TestCompiler()
{
- if (childProc)
- delete childProc;
}
-bool TestCompiler::runChild( bool showOutput, QStringList argList, QStringList *envList )
+bool TestCompiler::runCommand( QString cmdline )
{
- //qDebug() << "executing" << argList;
- exit_ok = FALSE;
- if (childProc)
- delete childProc;
-
- child_show = showOutput;
- if ( showOutput ) {
-
- QString S = argList.join(" ");
- addMakeResult( S );
- }
+ testOutput_.append("Running command: " + cmdline);
- childProc = new Q3Process(argList, this, argList.join(" ").latin1());
- Q_ASSERT(childProc);
-
- connect(childProc,SIGNAL(readyReadStdout()),this,SLOT(childHasData()));
- connect(childProc,SIGNAL(processExited()),this,SLOT(childReady()));
-
- if (!childProc->start( envList )) {
-
- addMakeResult( "Error executing '" + argList[0] + "'." );
- childReady();
- return FALSE;
+ QProcess child;
+ child.start(cmdline);
+ if (!child.waitForStarted(-1)) {
+ testOutput_.append( "Unable to start child process." );
+ return false;
}
- while (childProc != 0 && childProc->isRunning()) {
- qApp->processEvents();
+ bool failed = false;
+ child.setReadChannel(QProcess::StandardError);
+ while (QProcess::Running == child.state()) {
+ if (child.waitForReadyRead(1000)) {
+ QString output = child.readAllStandardError();
+ testOutput_.append(output);
+
+ output.prepend('\n');
+ if (output.contains("\nProject MESSAGE: FAILED"))
+ failed = true;
+ }
}
- childReady();
-
- return exit_ok;
-}
-
-void TestCompiler::childReady()
-{
- if (childProc != 0) {
- childHasData();
-
- QString S;
- int pos;
- while (childProc->canReadLineStderr()) {
- S = childProc->readLineStderr();
- do {
- pos = S.find("\t");
- if (pos >= 0) {
- S.remove(pos,1);
- S.insert(pos," ");
- }
- } while (pos >= 0);
-
- if (child_show)
- addMakeResult( S );
- }
+ child.waitForFinished(-1);
- exit_ok = childProc->normalExit() && childProc->exitStatus() == 0;
- delete childProc;
- }
- childProc = 0;
-}
-
-void TestCompiler::childHasData()
-{
- QString S;
- int pos;
- while (childProc->canReadLineStderr()) {
-
- S = childProc->readLineStderr();
- do {
- pos = S.find("\t");
- if (pos >= 0) {
- S.remove(pos,1);
- S.insert(pos," ");
- }
-
- } while (pos >= 0);
-
- if ( S.startsWith("Project MESSAGE: FAILED") )
- QTest::qFail( S, __FILE__, __LINE__ );
- else if ( S.startsWith("Project MESSAGE: SKIPPED") )
- QTest::qSkip( S, QTest::SkipSingle, __FILE__, __LINE__ );
- else if (child_show)
- addMakeResult( S );
- }
+ return failed
+ ? false
+ : (child.exitStatus() == QProcess::NormalExit)
+ && (child.exitCode() == 0);
}
-void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode )
+void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd )
{
- qws_mode = qwsMode;
- make_cmd = makeCmd;
-
- // not sure if i need this, but it doesn't hurt
- if (make_cmd.startsWith("\""))
- make_cmd = make_cmd.remove(0,1);
- if (make_cmd.endsWith("\""))
- make_cmd = make_cmd.remove(make_cmd.length()-1,1);
-
- qmake_cmd = qmakeCmd;
- // also not sure if i need this, but it doesn't hurt...
- if(qmake_cmd.length() >= 2 && (qmake_cmd.at(0) == '"' || qmake_cmd.at(0) == '\'') && qmake_cmd.at(qmake_cmd.length()-1) == qmake_cmd.at(0))
- qmake_cmd = qmake_cmd.mid(1, qmake_cmd.length()-2);
+ makeCmd_ = makeCmd;
+ qmakeCmd_ = qmakeCmd;
}
bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt )
@@ -256,7 +184,7 @@ bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, c
QDir D(workPath);
if (!D.exists()) {
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
+ testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
return FALSE;
}
@@ -269,11 +197,7 @@ bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, c
if (Fi.exists()) {
// Run make clean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("clean");
-
- return runChild( FALSE, args, 0 );
+ return runCommand( makeCmd_ + " clean" );
}
return TRUE;
@@ -284,7 +208,7 @@ bool TestCompiler::makeClean( const QString &workPath )
QDir D;
if (!D.exists(workPath)) {
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
+ testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
return FALSE;
}
@@ -293,11 +217,7 @@ bool TestCompiler::makeClean( const QString &workPath )
if (Fi.exists()) {
// Run make clean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("clean");
-
- return runChild( FALSE, args, 0 );
+ return runCommand( makeCmd_ + " clean" );
}
return TRUE;
@@ -307,20 +227,15 @@ bool TestCompiler::makeDistClean( const QString &workPath )
{
QDir D;
if (!D.exists(workPath)) {
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
+ testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
return FALSE;
}
D.setCurrent(workPath);
QFileInfo Fi( workPath + "/Makefile");
- if (Fi.exists()) {
- // Run make distclean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("distclean");
-
- return runChild( FALSE, args, 0 );
- }
+ if (Fi.exists())
+ // Run make distclean
+ return runCommand( makeCmd_ + " distclean" );
return TRUE;
@@ -328,26 +243,22 @@ bool TestCompiler::makeDistClean( const QString &workPath )
bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir )
{
- // Now start qmake and generate the makefile
-
- QDir D( workDir );
- // Make sure we start in the right directory
+ QDir D;
D.setCurrent( workDir );
if (D.exists("Makefile"))
- D.remove("Makefile");
-
- QStringList args;
- args = QStringList::split( " ", qmake_cmd );
+ D.remove("Makefile");
- QString project_fname = workDir + "/" + proName + ".pro";
- QString makefile_fname = (buildDir.isNull()?QString():(buildDir + "/")) + "Makefile";
+ QString projectFile = proName;
+ QString makeFile = buildDir;
+ if (!projectFile.endsWith(".pro"))
+ projectFile += ".pro";
+ if (!makeFile.isEmpty() && !makeFile.endsWith('/'))
+ makeFile += '/';
+ makeFile += "Makefile";
- args.append( project_fname );
- args.append( "-o" );
- args.append( makefile_fname );
-
- return runChild( TRUE, args, 0 );
+ // Now start qmake and generate the makefile
+ return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile );
}
bool TestCompiler::make( const QString &workPath, const QString &target )
@@ -355,14 +266,13 @@ bool TestCompiler::make( const QString &workPath, const QString &target )
QDir D;
D.setCurrent( workPath );
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- if ( make_cmd.lower().find("nmake") >= 0)
- args.append("/NOLOGO");
- if ( !target.isNull() )
- args.append(target);
+ QString cmdline = makeCmd_;
+ if ( cmdline.contains("nmake", Qt::CaseInsensitive) )
+ cmdline.append(" /NOLOGO");
+ if ( !target.isEmpty() )
+ cmdline += " " + target;
- return runChild( TRUE, args, 0 );
+ return runCommand( cmdline );
}
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )
@@ -371,10 +281,6 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build
return f.exists();
}
-void TestCompiler::addMakeResult( const QString &result )
-{
- make_result.append( result );
-}
bool TestCompiler::removeMakefile( const QString &workPath )
{
@@ -385,6 +291,3 @@ bool TestCompiler::removeMakefile( const QString &workPath )
else
return TRUE;
}
-
-#endif //QT3_SUPPORT
-
diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h
index 597d440..12d8878 100644
--- a/tests/auto/qmake/testcompiler.h
+++ b/tests/auto/qmake/testcompiler.h
@@ -41,14 +41,9 @@
#ifndef TESTCOMPILER_H
#define TESTCOMPILER_H
-
-#ifdef QT3_SUPPORT
-
#include <qobject.h>
#include <qstringlist.h>
-QT_FORWARD_DECLARE_CLASS(Q3Process)
-
#define COMPILE_ERROR "Compile error"
#define COMPILE_SUCCESS "Compile successfull"
#define COMPILE_NOT_AVAIL "Binary not available for testing"
@@ -64,7 +59,7 @@ public:
TestCompiler();
virtual ~TestCompiler();
- void setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode );
+ void setBaseCommands( QString makeCmd, QString qmakeCmd );
// builds a complete project, e.g. qmake, make clean, make and exists.
bool buildProject( const QString &project, BuildType buildType, const QString &targetName, const QString &destPath, const QString &version );
@@ -86,25 +81,13 @@ public:
bool removeMakefile( const QString &workPath );
private:
- QString make_cmd;
- QString qmake_cmd;
+ bool runCommand( QString cmdLine );
- Q3Process *childProc;
- QStringList env_list;
-
- bool child_show;
- bool qws_mode;
- bool exit_ok;
-
-private:
- bool runChild( bool showOutput, QStringList argList, QStringList *envList );
- void addMakeResult( const QString &result );
- QStringList make_result;
+ QString makeCmd_;
+ QString qmakeCmd_;
-private slots:
- void childReady();
- void childHasData();
+ // need to make this available somewhere
+ QStringList testOutput_;
};
-#endif // QT3_SUPPORT
#endif // TESTCOMPILER_H
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index facf0bb..884a2c4 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -42,11 +42,9 @@
#include <QtTest/QtTest>
-#if !defined(QMAKE_CROSS_COMPILED) && defined(QT3_SUPPORT)
+#if !defined(QMAKE_CROSS_COMPILED)
#include <qdir.h>
-#include <qprocess.h>
-
#include "testcompiler.h"
@@ -104,16 +102,16 @@ tst_qmake::tst_qmake()
{
QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION);
#ifdef Q_CC_MSVC
- test_compiler.setBaseCommands( "nmake", cmd, FALSE );
+ test_compiler.setBaseCommands( "nmake", cmd );
#elif defined(Q_CC_MINGW)
- test_compiler.setBaseCommands( "mingw32-make", cmd, FALSE );
+ test_compiler.setBaseCommands( "mingw32-make", cmd );
#elif defined(Q_OS_WIN) && defined(Q_CC_GNU)
- test_compiler.setBaseCommands( "mmmake", cmd, FALSE );
+ test_compiler.setBaseCommands( "mmmake", cmd );
#else
- test_compiler.setBaseCommands( "make", cmd, FALSE );
+ test_compiler.setBaseCommands( "make", cmd );
#endif
QDir dir;
- base_path = dir.currentDirPath();
+ base_path = dir.currentPath();
}
tst_qmake::~tst_qmake()
@@ -406,7 +404,7 @@ void tst_qmake::bundle_spaces()
// make (-n).
TestCompiler local_tc;
- local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++", FALSE);
+ local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++");
QVERIFY( local_tc.qmake(workDir, "bundle-spaces") );