summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto@kdab.com>2012-08-10 17:21:30 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-04 10:30:33 +0200
commit3d4fc578bd5cc0b6d39d16638aa6f3577eb31f69 (patch)
treedeb4fa0473e37de48a6a299a0f9a6b65aea29f47
parent53d0829aa1552dd1c7d5da008ec4b1a4052a7e5a (diff)
Auto test for 'qmake -project' use case.
Change-Id: Ifb6d64828ba1cb42fd64299438b7eec302112edf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rw-r--r--tests/auto/tools/qmake/testcompiler.cpp36
-rw-r--r--tests/auto/tools/qmake/testcompiler.h6
-rw-r--r--tests/auto/tools/qmake/testdata/project/main.cpp50
-rw-r--r--tests/auto/tools/qmake/testdata/project/test.qrc5
-rw-r--r--tests/auto/tools/qmake/testdata/project/test_file.cpp46
-rw-r--r--tests/auto/tools/qmake/testdata/project/test_file.h51
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp15
7 files changed, 205 insertions, 4 deletions
diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp
index 3b77b1ec63..223f212141 100644
--- a/tests/auto/tools/qmake/testcompiler.cpp
+++ b/tests/auto/tools/qmake/testcompiler.cpp
@@ -244,6 +244,22 @@ bool TestCompiler::makeDistClean( const QString &workPath )
}
+bool TestCompiler::qmakeProject( const QString &workDir, const QString &proName )
+{
+ QDir D;
+ if (!D.exists(workDir)) {
+ testOutput_.append( "Directory '" + workDir + "' doesn't exist" );
+ return errorOut();
+ }
+ D.setCurrent(workDir);
+
+ QString projectFile = proName;
+ if (!projectFile.endsWith(".pro"))
+ projectFile += ".pro";
+
+ return runCommand(qmakeCmd_ + " -project -o " + projectFile + " DESTDIR=./");
+}
+
bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir )
{
QDir D;
@@ -286,12 +302,24 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build
bool TestCompiler::removeMakefile( const QString &workPath )
{
+ return removeFile( workPath, "Makefile" );
+}
+
+bool TestCompiler::removeProject( const QString &workPath, const QString &project )
+{
+ QString projectFile = project;
+ if (!projectFile.endsWith(".pro"))
+ projectFile += ".pro";
+
+ return removeFile( workPath, projectFile );
+}
+
+bool TestCompiler::removeFile( const QString &workPath, const QString &fileName )
+{
QDir D;
D.setCurrent( workPath );
- if ( D.exists( "Makefile" ) )
- return D.remove( "Makefile" );
- else
- return true;
+
+ return ( D.exists( fileName ) ) ? D.remove( fileName ) : true;
}
QString TestCompiler::commandOutput() const
diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h
index 8aed3a9987..137ffc9f54 100644
--- a/tests/auto/tools/qmake/testcompiler.h
+++ b/tests/auto/tools/qmake/testcompiler.h
@@ -66,6 +66,8 @@ public:
bool makeClean( const QString &workPath );
// executes a make dist clean in the specified workPath
bool makeDistClean( const QString &workPath );
+ // executes a qmake -project on the specified workDir
+ bool qmakeProject( const QString &workDir, const QString &proName );
// 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)
@@ -74,6 +76,10 @@ public:
bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version );
// removes the makefile
bool removeMakefile( const QString &workPath );
+ // removes the project file specified by 'project' on the 'workPath'
+ bool removeProject( const QString &workPath, const QString &project );
+ // removes the file specified by 'fileName' on the 'workPath'
+ bool removeFile( const QString &workPath, const QString &fileName );
// returns each line of stdout of the last command append with a "new line" character(s) to suit the platform
QString commandOutput() const;
// clear the results of storage of stdout for running previous commands
diff --git a/tests/auto/tools/qmake/testdata/project/main.cpp b/tests/auto/tools/qmake/testdata/project/main.cpp
new file mode 100644
index 0000000000..356d2176a4
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/project/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "test_file.h"
+#include <qguiapplication.h>
+
+int main( int argc, char **argv )
+{
+ QGuiApplication a(argc, argv);
+ SomeObject sc;
+ return a.exec();
+}
diff --git a/tests/auto/tools/qmake/testdata/project/test.qrc b/tests/auto/tools/qmake/testdata/project/test.qrc
new file mode 100644
index 0000000000..decde3dd24
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/project/test.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>test.qrc</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/tools/qmake/testdata/project/test_file.cpp b/tests/auto/tools/qmake/testdata/project/test_file.cpp
new file mode 100644
index 0000000000..cf67fb5767
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/project/test_file.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "test_file.h"
+
+SomeObject::SomeObject() : QObject()
+{
+}
diff --git a/tests/auto/tools/qmake/testdata/project/test_file.h b/tests/auto/tools/qmake/testdata/project/test_file.h
new file mode 100644
index 0000000000..955486d67d
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/project/test_file.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qobject.h>
+
+class SomeObject : public QObject
+{
+ Q_OBJECT
+public:
+ SomeObject();
+signals:
+ void someSignal();
+};
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index 3d1faf2aac..54032ad750 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -89,6 +89,7 @@ private slots:
#endif
void includefunction();
void substitutes();
+ void project();
private:
TestCompiler test_compiler;
@@ -516,5 +517,19 @@ void tst_qmake::substitutes()
QVERIFY( test_compiler.makeDistClean( buildDir ));
}
+void tst_qmake::project()
+{
+ QString workDir = base_path + "/testdata/project";
+
+ QVERIFY( test_compiler.qmakeProject( workDir, "project" ));
+ QVERIFY( test_compiler.exists( workDir, "project.pro", Plain, "" ));
+ QVERIFY( test_compiler.qmake( workDir, "project" ));
+ QVERIFY( test_compiler.exists( workDir, "Makefile", Plain, "" ));
+ QVERIFY( test_compiler.make( workDir ));
+ QVERIFY( test_compiler.exists( workDir, "project", Exe, "" ));
+ QVERIFY( test_compiler.makeDistClean( workDir ));
+ QVERIFY( test_compiler.removeProject( workDir, "project" ));
+}
+
QTEST_MAIN(tst_qmake)
#include "tst_qmake.moc"