Auto test for 'qmake -project' use case.

Change-Id: Ifb6d64828ba1cb42fd64299438b7eec302112edf
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
Rafael Roquetto 2012-08-10 17:21:30 +02:00 committed by Qt by Nokia
parent 53d0829aa1
commit 3d4fc578bd
7 changed files with 205 additions and 4 deletions

View File

@ -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;
@ -285,13 +301,25 @@ 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

View File

@ -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

View File

@ -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();
}

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>test.qrc</file>
</qresource>
</RCC>

View File

@ -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()
{
}

View File

@ -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();
};

View File

@ -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"