Auto test for 'qmake -project' use case.
Change-Id: Ifb6d64828ba1cb42fd64299438b7eec302112edf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
parent
53d0829aa1
commit
3d4fc578bd
@ -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 )
|
bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir )
|
||||||
{
|
{
|
||||||
QDir D;
|
QDir D;
|
||||||
@ -285,13 +301,25 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TestCompiler::removeMakefile( const QString &workPath )
|
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;
|
QDir D;
|
||||||
D.setCurrent( workPath );
|
D.setCurrent( workPath );
|
||||||
if ( D.exists( "Makefile" ) )
|
|
||||||
return D.remove( "Makefile" );
|
return ( D.exists( fileName ) ) ? D.remove( fileName ) : true;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TestCompiler::commandOutput() const
|
QString TestCompiler::commandOutput() const
|
||||||
|
@ -66,6 +66,8 @@ public:
|
|||||||
bool makeClean( const QString &workPath );
|
bool makeClean( const QString &workPath );
|
||||||
// executes a make dist clean in the specified workPath
|
// executes a make dist clean in the specified workPath
|
||||||
bool makeDistClean( const QString &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
|
// 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() );
|
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)
|
// 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 );
|
bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version );
|
||||||
// removes the makefile
|
// removes the makefile
|
||||||
bool removeMakefile( const QString &workPath );
|
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
|
// returns each line of stdout of the last command append with a "new line" character(s) to suit the platform
|
||||||
QString commandOutput() const;
|
QString commandOutput() const;
|
||||||
// clear the results of storage of stdout for running previous commands
|
// clear the results of storage of stdout for running previous commands
|
||||||
|
50
tests/auto/tools/qmake/testdata/project/main.cpp
vendored
Normal file
50
tests/auto/tools/qmake/testdata/project/main.cpp
vendored
Normal 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();
|
||||||
|
}
|
5
tests/auto/tools/qmake/testdata/project/test.qrc
vendored
Normal file
5
tests/auto/tools/qmake/testdata/project/test.qrc
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>test.qrc</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
46
tests/auto/tools/qmake/testdata/project/test_file.cpp
vendored
Normal file
46
tests/auto/tools/qmake/testdata/project/test_file.cpp
vendored
Normal 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()
|
||||||
|
{
|
||||||
|
}
|
51
tests/auto/tools/qmake/testdata/project/test_file.h
vendored
Normal file
51
tests/auto/tools/qmake/testdata/project/test_file.h
vendored
Normal 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();
|
||||||
|
};
|
@ -89,6 +89,7 @@ private slots:
|
|||||||
#endif
|
#endif
|
||||||
void includefunction();
|
void includefunction();
|
||||||
void substitutes();
|
void substitutes();
|
||||||
|
void project();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestCompiler test_compiler;
|
TestCompiler test_compiler;
|
||||||
@ -516,5 +517,19 @@ void tst_qmake::substitutes()
|
|||||||
QVERIFY( test_compiler.makeDistClean( buildDir ));
|
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)
|
QTEST_MAIN(tst_qmake)
|
||||||
#include "tst_qmake.moc"
|
#include "tst_qmake.moc"
|
||||||
|
Loading…
Reference in New Issue
Block a user