diff options
Diffstat (limited to 'tests/auto/blackbox')
24 files changed, 1185 insertions, 0 deletions
diff --git a/tests/auto/blackbox/blackbox.pro b/tests/auto/blackbox/blackbox.pro new file mode 100644 index 000000000..40d1a5dea --- /dev/null +++ b/tests/auto/blackbox/blackbox.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +TARGET = testBlackbox +DEPENDPATH += . +DESTDIR = ../../../bin/ +INCLUDEPATH += . ../../../src/lib/ +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +QT = core script testlib + +include(../../../src/lib/use.pri) + +SOURCES += \ + tst_blackbox.cpp + diff --git a/tests/auto/blackbox/testdata/buildproperties_source/bp_source.qbp b/tests/auto/blackbox/testdata/buildproperties_source/bp_source.qbp new file mode 100644 index 000000000..0d6cb5741 --- /dev/null +++ b/tests/auto/blackbox/testdata/buildproperties_source/bp_source.qbp @@ -0,0 +1,16 @@ +import qbs.base 1.0 + +Project { + Product { + type: "application" + name: "HelloWorld" + + Depends { name: 'cpp' } + + Group { + cpp.defines: ['WORLD="BANANA"'] + files : [ "main.cpp" ] + } + } +} + diff --git a/tests/auto/blackbox/testdata/buildproperties_source/main.cpp b/tests/auto/blackbox/testdata/buildproperties_source/main.cpp new file mode 100644 index 000000000..fbae63cf0 --- /dev/null +++ b/tests/auto/blackbox/testdata/buildproperties_source/main.cpp @@ -0,0 +1,47 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +#include <stdio.h> + +#ifndef WORLD +# error WORLD is not defined +#endif + +int main() +{ + puts("Hello " WORLD "!"); +} diff --git a/tests/auto/blackbox/testdata/moc_h/bla.cpp b/tests/auto/blackbox/testdata/moc_h/bla.cpp new file mode 100644 index 000000000..9045af23d --- /dev/null +++ b/tests/auto/blackbox/testdata/moc_h/bla.cpp @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +#include "bla.h" + +int main() +{ + MyObject obj; + obj.setObjectName("I am the object!"); +} diff --git a/tests/auto/blackbox/testdata/moc_h/bla_noqobject.h b/tests/auto/blackbox/testdata/moc_h/bla_noqobject.h new file mode 100644 index 000000000..54e7cbd8f --- /dev/null +++ b/tests/auto/blackbox/testdata/moc_h/bla_noqobject.h @@ -0,0 +1,43 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +#include <QObject> + +class MyObject : public QObject +{ +}; + diff --git a/tests/auto/blackbox/testdata/moc_h/bla_qobject.h b/tests/auto/blackbox/testdata/moc_h/bla_qobject.h new file mode 100644 index 000000000..4f58ed10a --- /dev/null +++ b/tests/auto/blackbox/testdata/moc_h/bla_qobject.h @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +}; + diff --git a/tests/auto/blackbox/testdata/moc_h/i.qbp b/tests/auto/blackbox/testdata/moc_h/i.qbp new file mode 100644 index 000000000..0e103ecd9 --- /dev/null +++ b/tests/auto/blackbox/testdata/moc_h/i.qbp @@ -0,0 +1,18 @@ +import qbs.base 1.0 + +Project { + Product { + type: "application" + name: "i" + + Depends { + name: "Qt.core" + } + + files: [ + "bla.cpp", + "bla.h" + ] + } +} + diff --git a/tests/auto/blackbox/testdata/qrc/bla.cpp b/tests/auto/blackbox/testdata/qrc/bla.cpp new file mode 100644 index 000000000..cbb85fa03 --- /dev/null +++ b/tests/auto/blackbox/testdata/qrc/bla.cpp @@ -0,0 +1,42 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +int main() +{ + return 3; +} + diff --git a/tests/auto/blackbox/testdata/qrc/bla.qrc b/tests/auto/blackbox/testdata/qrc/bla.qrc new file mode 100644 index 000000000..46c93847e --- /dev/null +++ b/tests/auto/blackbox/testdata/qrc/bla.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>stuff.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/blackbox/testdata/qrc/i.qbp b/tests/auto/blackbox/testdata/qrc/i.qbp new file mode 100644 index 000000000..11b9d1be3 --- /dev/null +++ b/tests/auto/blackbox/testdata/qrc/i.qbp @@ -0,0 +1,19 @@ +import qbs.base 1.0 + +Project { + Product { + type: "application" + name: "i" + + Depends { + name: "Qt.core" + } + + files: [ + "bla.cpp", + "bla.qrc", + "stuff.txt" + ] + } +} + diff --git a/tests/auto/blackbox/testdata/qrc/stuff.txt b/tests/auto/blackbox/testdata/qrc/stuff.txt new file mode 100644 index 000000000..78f0d32c6 --- /dev/null +++ b/tests/auto/blackbox/testdata/qrc/stuff.txt @@ -0,0 +1 @@ +a resource file diff --git a/tests/auto/blackbox/testdata/trackAddFile/after/main.cpp b/tests/auto/blackbox/testdata/trackAddFile/after/main.cpp new file mode 100644 index 000000000..749b6c2d1 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/after/main.cpp @@ -0,0 +1,50 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include "narf.h" +#include "zort.h" +#include <cstdio> + +int main(int argc, char **argv) +{ + printf("Hello World!\n"); + Narf narf; + narf.shout(); + Zort zort; + zort.shout(); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/trackAddFile/after/project.qbp b/tests/auto/blackbox/testdata/trackAddFile/after/project.qbp new file mode 100644 index 000000000..2e3a56102 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/after/project.qbp @@ -0,0 +1,15 @@ +import qbs.base 1.0 + +Project { + Product { + name: 'someapp' + type: 'application' + Depends { name: 'cpp' } + files: [ + "main.cpp", + "narf.h", "narf.cpp", + "zort.h", "zort.cpp" + ] + } +} + diff --git a/tests/auto/blackbox/testdata/trackAddFile/after/zort.cpp b/tests/auto/blackbox/testdata/trackAddFile/after/zort.cpp new file mode 100644 index 000000000..336ff5fda --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/after/zort.cpp @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include "zort.h" +#include <cstdio> + +void Zort::shout() +{ + printf("ZORT!\n"); +} + diff --git a/tests/auto/blackbox/testdata/trackAddFile/after/zort.h b/tests/auto/blackbox/testdata/trackAddFile/after/zort.h new file mode 100644 index 000000000..b94b70e27 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/after/zort.h @@ -0,0 +1,47 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#ifndef ZORT_H +#define ZORT_H + +class Zort +{ +public: + void shout(); +}; + +#endif + diff --git a/tests/auto/blackbox/testdata/trackAddFile/before/main.cpp b/tests/auto/blackbox/testdata/trackAddFile/before/main.cpp new file mode 100644 index 000000000..2fec2b365 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/before/main.cpp @@ -0,0 +1,47 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include "narf.h" +#include <cstdio> + +int main(int argc, char **argv) +{ + printf("Hello World!\n"); + Narf narf; + narf.shout(); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/trackAddFile/before/narf.cpp b/tests/auto/blackbox/testdata/trackAddFile/before/narf.cpp new file mode 100644 index 000000000..5c04c9d7c --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/before/narf.cpp @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include "narf.h" +#include <cstdio> + +void Narf::shout() +{ + printf("NARF!\n"); +} + diff --git a/tests/auto/blackbox/testdata/trackAddFile/before/narf.h b/tests/auto/blackbox/testdata/trackAddFile/before/narf.h new file mode 100644 index 000000000..afc73511f --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/before/narf.h @@ -0,0 +1,47 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#ifndef NARF_H +#define NARF_H + +class Narf +{ +public: + void shout(); +}; + +#endif + diff --git a/tests/auto/blackbox/testdata/trackAddFile/before/project.qbp b/tests/auto/blackbox/testdata/trackAddFile/before/project.qbp new file mode 100644 index 000000000..222788b6a --- /dev/null +++ b/tests/auto/blackbox/testdata/trackAddFile/before/project.qbp @@ -0,0 +1,11 @@ +import qbs.base 1.0 + +Project { + Product { + name: 'someapp' + type: 'application' + Depends { name: 'cpp' } + files: [ "main.cpp", "narf.h", "narf.cpp" ] + } +} + diff --git a/tests/auto/blackbox/testdata/trackFileTags/after/main.cpp b/tests/auto/blackbox/testdata/trackFileTags/after/main.cpp new file mode 100644 index 000000000..fb5a86b9c --- /dev/null +++ b/tests/auto/blackbox/testdata/trackFileTags/after/main.cpp @@ -0,0 +1,46 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include <cstdio> + +int foo(); + +int main(int argc, char **argv) +{ + printf("there's %d foo here\n", foo()); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/trackFileTags/after/project.qbp b/tests/auto/blackbox/testdata/trackFileTags/after/project.qbp new file mode 100644 index 000000000..453658e98 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackFileTags/after/project.qbp @@ -0,0 +1,51 @@ +import qbs.base 1.0 + +Project { + Product { + name: 'someapp' + type: 'application' + Depends { name: 'cpp' } + Group { + files: [ "main.cpp" ] + fileTags: [ "foosource", "cpp" ] + } + } + + Rule { + inputs: ["foosource"] + Artifact { + fileName: input.baseName + ".foo" + fileTags: ["foo"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = "var file = new TextFile(output.fileName, TextFile.WriteOnly);"; + cmd.sourceCode += "file.truncate();" + cmd.sourceCode += "file.write(\"There's nothing to see here!\");" + cmd.sourceCode += "file.close();" + cmd.description = "generating something"; + return cmd; + } + } + + Rule { + inputs: ["foo"] + Artifact { + fileName: input.baseName + "_foo.cpp" + fileTags: ["cpp"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = "var file = new TextFile(output.fileName, TextFile.WriteOnly);"; + cmd.sourceCode += "file.truncate();"; + cmd.sourceCode += "file.write(\"// There's nothing to see here!\\n\");"; + cmd.sourceCode += "file.write(\"int foo() { return 15; }\\n\");"; + cmd.sourceCode += "file.close();"; + cmd.description = "generating something"; + return cmd; + } + } +} + diff --git a/tests/auto/blackbox/testdata/trackFileTags/before/main.cpp b/tests/auto/blackbox/testdata/trackFileTags/before/main.cpp new file mode 100644 index 000000000..fe6c86168 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackFileTags/before/main.cpp @@ -0,0 +1,44 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ +#include <cstdio> + +int main(int argc, char **argv) +{ + printf("there's no foo here\n"); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/trackFileTags/before/project.qbp b/tests/auto/blackbox/testdata/trackFileTags/before/project.qbp new file mode 100644 index 000000000..50400f157 --- /dev/null +++ b/tests/auto/blackbox/testdata/trackFileTags/before/project.qbp @@ -0,0 +1,51 @@ +import qbs.base 1.0 + +Project { + Product { + name: 'someapp' + type: 'application' + Depends { name: 'cpp' } + Group { + files: [ "main.cpp" ] + fileTags: [ "cpp" ] + } + } + + Rule { + inputs: ["foosource"] + Artifact { + fileName: input.baseName + ".foo" + fileTags: ["foo"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = "var file = new TextFile(output.fileName, TextFile.WriteOnly);"; + cmd.sourceCode += "file.truncate();" + cmd.sourceCode += "file.write(\"There's nothing to see here!\");" + cmd.sourceCode += "file.close();" + cmd.description = "generating something"; + return cmd; + } + } + + Rule { + inputs: ["foo"] + Artifact { + fileName: input.baseName + "_foo.cpp" + fileTags: ["cpp"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = "var file = new TextFile(output.fileName, TextFile.WriteOnly);"; + cmd.sourceCode += "file.truncate();"; + cmd.sourceCode += "file.write(\"// There's nothing to see here!\\n\");"; + cmd.sourceCode += "file.write(\"int foo() { return 15; }\\n\");"; + cmd.sourceCode += "file.close();"; + cmd.description = "generating something"; + return cmd; + } + } +} + diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp new file mode 100644 index 000000000..9bf6b7d87 --- /dev/null +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -0,0 +1,395 @@ +/************************************************************************** +** +** This file is part of the Qt Build Suite +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** 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. +** +**************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtCore/QProcess> +#include <QtCore/QFile> +#include <QtCore/QCoreApplication> +#include <QtTest/QtTest> + +#ifdef Q_OS_LINUX +#include <unistd.h> +#endif + +class TestBlackbox : public QObject +{ + Q_OBJECT + const QString testDataDir; + const QString testSourceDir; + const QString executableSuffix; + const QString objectSuffix; +public: + TestBlackbox() + : testDataDir(QCoreApplication::applicationDirPath() + "/testdata"), + testSourceDir(QDir::cleanPath(SRCDIR "/testdata")), + #ifdef Q_OS_WIN + executableSuffix(QLatin1String(".exe")), + #else + executableSuffix(QLatin1String("")), + #endif + #ifdef Q_OS_WIN + objectSuffix(QLatin1String(".obj")) + #else + objectSuffix(QLatin1String(".o")) + #endif + { + } + +protected: + + int runQbs(QStringList arguments = QStringList(), bool showOutput = false) + { + QString cmdLine = QCoreApplication::applicationDirPath() + "/qbs"; + foreach (const QString &str, arguments) + cmdLine += QLatin1String(" \"") + str + QLatin1Char('"'); + + int r; + if (showOutput) { + r = system(cmdLine.toLatin1()); + } else { + QProcess process; + process.start(cmdLine); + process.waitForStarted(); + process.waitForFinished(); + r = process.exitCode(); + } + return r; + } + + /*! + Recursive copy from directory to another. + Note that this updates the file stamps on Linux but not on Windows. + */ + void ccp(const QString &from, const QString &to) + { + QDirIterator it(from, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); + while (it.hasNext()) { + it.next(); + QDir().mkpath(to + "/" + it.fileName()); + ccp(from + "/" + it.fileName(), to + "/" + it.fileName()); + } + + QDirIterator it2(from, QDir::Files| QDir::NoDotAndDotDot | QDir::Hidden); + while (it2.hasNext()) { + it2.next(); + const QString dstFilePath = to + "/" + it2.fileName(); + if (QFile::exists(dstFilePath)) + QFile::remove(dstFilePath); + QFile(from + "/" + it2.fileName()).copy(dstFilePath); + } + } + + void rmDirR(const QString &dir) + { + QDirIterator it(dir, QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden); + while (it.hasNext()) { + QFile(it.next()).remove(); + } + + QDirIterator it2(dir, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); + while (it2.hasNext()) { + rmDirR(it2.next()); + } + QDir().rmdir(dir); + } + + void touch(const QString &fn) + { + QFile f(fn); + int s = f.size(); + if (!f.open(QFile::ReadWrite)) + qFatal("cannot open file %s", qPrintable(fn)); + f.resize(s+1); + f.resize(s); + } + +public slots: + void init() + { + rmDirR(testDataDir); + QDir().mkpath(testDataDir); + ccp(testSourceDir, testDataDir); + } + + void cleanup() + { +// rmDirR(testDataDir); + } + +private slots: + void build_project_data() + { + QTest::addColumn<QString>("projectSubDir"); + QTest::addColumn<QString>("productFileName"); + QTest::newRow("BPs in Sources") + << QString("buildproperties_source") + << QString("build/debug/HelloWorld"); + } + + void build_project() + { + QFETCH(QString, projectSubDir); + QFETCH(QString, productFileName); + if (!projectSubDir.startsWith('/')) + projectSubDir.prepend('/'); + QDir::setCurrent(testDataDir + projectSubDir); + qDebug() << "currentdir set" << testDataDir + projectSubDir; + qDebug() << "currentdir" << QDir::currentPath(); + productFileName.append(executableSuffix); + QCOMPARE(runQbs(), 0); + QVERIFY(QFile::exists(productFileName)); + QVERIFY(QFile::remove(productFileName)); + QCOMPARE(runQbs(), 0); + QVERIFY(QFile::exists(productFileName)); + } + + void track_qrc() + { + QDir::setCurrent(testDataDir + "/qrc"); + QCOMPARE(runQbs(), 0); + QString fileName = "build/debug/i" + executableSuffix; + QVERIFY(QFile(fileName).exists()); + QDateTime dt = QFileInfo(fileName).lastModified(); + QTest::qSleep(2020); + { + QFile f("stuff.txt"); + f.remove(); + QVERIFY(f.open(QFile::WriteOnly)); + f.write("bla"); + f.close(); + } + QCOMPARE(runQbs(), 0); + QVERIFY(QFile(fileName).exists()); + QVERIFY(dt < QFileInfo(fileName).lastModified()); + } + + void track_qobject_change() + { + QDir::setCurrent(testDataDir + "/moc_h"); + QFile("bla.h").remove(); + QVERIFY(QFile("bla_qobject.h").copy("bla.h")); + touch("bla.h"); + QCOMPARE(runQbs(), 0); + QVERIFY(QFile("build/debug/i" + executableSuffix).exists()); + QString moc_bla_objectFileName = "build/debug/.obj/i/GeneratedFiles/i/moc_bla" + objectSuffix; + QVERIFY(QFile(moc_bla_objectFileName).exists()); + + QTest::qSleep(1000); + QFile("bla.h").remove(); + QVERIFY(QFile("bla_noqobject.h").copy("bla.h")); + touch("bla.h"); + QCOMPARE(runQbs(), 0); + QVERIFY(QFile("build/debug/i" + executableSuffix).exists()); + QVERIFY(!QFile(moc_bla_objectFileName).exists()); + } + + void trackAddFile() + { + QProcess process; + QList<QByteArray> output; + QDir::setCurrent(testDataDir + "/trackAddFile"); + if (QFile::exists("work")) + rmDirR("work"); + QDir().mkdir("work"); + ccp("before", "work"); + QDir::setCurrent(testDataDir + "/trackAddFile/work"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "Hello World!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "NARF!"); + QString unchangedObjectFile = "build/debug/someapp/narf" + objectSuffix; + QDateTime unchangedObjectFileTime1 = QFileInfo(unchangedObjectFile).lastModified(); + + QTest::qWait(1000); // for file systems with low resolution timestamps + ccp("../after", "."); + touch("project.qbp"); + touch("main.cpp"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "Hello World!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "NARF!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "ZORT!"); + + // the object file of the untouched source should not have changed + QDateTime unchangedObjectFileTime2 = QFileInfo(unchangedObjectFile).lastModified(); + QCOMPARE(unchangedObjectFileTime1, unchangedObjectFileTime2); + } + + void trackRemoveFile() + { + QProcess process; + QList<QByteArray> output; + QDir::setCurrent(testDataDir + "/trackAddFile"); + if (QFile::exists("work")) + rmDirR("work"); + QDir().mkdir("work"); + ccp("before", "work"); + ccp("after", "work"); + QDir::setCurrent(testDataDir + "/trackAddFile/work"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "Hello World!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "NARF!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "ZORT!"); + QString unchangedObjectFile = "build/debug/someapp/narf" + objectSuffix; + QDateTime unchangedObjectFileTime1 = QFileInfo(unchangedObjectFile).lastModified(); + + QTest::qWait(1000); // for file systems with low resolution timestamps + QFile::remove("project.qbp"); + QFile::remove("main.cpp"); + ccp("../before/project.qbp", "."); + ccp("../before/main.cpp", "."); + QFile::copy("../before/project.qbp", "project.qbp"); + QFile::copy("../before/main.cpp", "main.cpp"); + QVERIFY(QFile::remove("zort.h")); + QVERIFY(QFile::remove("zort.cpp")); + touch("main.cpp"); + touch("project.qbp"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "Hello World!"); + QCOMPARE(output.takeFirst().trimmed().constData(), "NARF!"); + + // the object file of the untouched source should not have changed + QDateTime unchangedObjectFileTime2 = QFileInfo(unchangedObjectFile).lastModified(); + QCOMPARE(unchangedObjectFileTime1, unchangedObjectFileTime2); + + // the object file for the removed cpp file should have vanished too + QCOMPARE(QFile::exists("build/debug/someapp/zort" + objectSuffix), false); + } + + void trackAddFileTag() + { + QProcess process; + QList<QByteArray> output; + QDir::setCurrent(testDataDir + "/trackFileTags"); + if (QFile::exists("work")) + rmDirR("work"); + QDir().mkdir("work"); + ccp("before", "work"); + QDir::setCurrent(testDataDir + "/trackFileTags/work"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "there's no foo here"); + + QTest::qWait(1000); // for file systems with low resolution timestamps + ccp("../after", "."); + touch("main.cpp"); + touch("project.qbp"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "there's 15 foo here"); + } + + void trackRemoveFileTag() + { + QProcess process; + QList<QByteArray> output; + QDir::setCurrent(testDataDir + "/trackFileTags"); + if (QFile::exists("work")) + rmDirR("work"); + QDir().mkdir("work"); + ccp("after", "work"); + QDir::setCurrent(testDataDir + "/trackFileTags/work"); + QCOMPARE(runQbs(), 0); + + // check if the artifacts are here that will become stale in the 2nd step + QCOMPARE(QFile::exists("build/debug/.obj/someapp/main_foo" + objectSuffix), true); + QCOMPARE(QFile::exists("build/debug/main_foo.cpp"), true); + QCOMPARE(QFile::exists("build/debug/main.foo"), true); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "there's 15 foo here"); + + QTest::qWait(1000); // for file systems with low resolution timestamps + ccp("../before", "."); + touch("main.cpp"); + touch("project.qbp"); + QCOMPARE(runQbs(), 0); + + process.start("build/debug/someapp"); + QVERIFY(process.waitForStarted()); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitCode(), 0); + output = process.readAllStandardOutput().split('\n'); + QCOMPARE(output.takeFirst().trimmed().constData(), "there's no foo here"); + + // check if stale artifacts have been removed + QCOMPARE(QFile::exists("build/debug/someapp/main_foo" + objectSuffix), false); + QCOMPARE(QFile::exists("build/debug/someapp/main_foo.cpp"), false); + QCOMPARE(QFile::exists("build/debug/someapp/main.foo"), false); + } + +}; + +QTEST_MAIN(TestBlackbox) + +#include "tst_blackbox.moc" |