diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-10-10 17:26:33 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-10-14 23:23:45 +0200 |
commit | c8b795532c5b5fa0752e218ab5b75c1569a2c5c1 (patch) | |
tree | 398974b7a781f3dee425eb608dfd58399b3689e7 /tests/auto/blackbox | |
parent | c939d3bb79619229626ccd02ea7deabe5debf060 (diff) |
Spring cleaning in manual tests.
Fix the ones that are broken, remove outdated constructs, turn into
autotest where it seems sensible.
Change-Id: I0fa7e95af4e49ea190b739f779ddf7e4e8b6f96a
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/blackbox')
32 files changed, 1034 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/baseProperties/imports/Bar.qbs b/tests/auto/blackbox/testdata/baseProperties/imports/Bar.qbs new file mode 100644 index 000000000..07ab724e4 --- /dev/null +++ b/tests/auto/blackbox/testdata/baseProperties/imports/Bar.qbs @@ -0,0 +1,6 @@ +import qbs 1.0 + +Product { + Depends { name: "cpp" } + cpp.defines: ["FROM_BAR"] +} diff --git a/tests/auto/blackbox/testdata/baseProperties/imports/Foo.qbs b/tests/auto/blackbox/testdata/baseProperties/imports/Foo.qbs new file mode 100644 index 000000000..563992434 --- /dev/null +++ b/tests/auto/blackbox/testdata/baseProperties/imports/Foo.qbs @@ -0,0 +1,7 @@ +import qbs 1.0 + +Bar { + type: "application" + cpp.defines: base.concat(["FROM_FOO"]) +} + diff --git a/tests/auto/blackbox/testdata/baseProperties/main.cpp b/tests/auto/blackbox/testdata/baseProperties/main.cpp new file mode 100644 index 000000000..79c0af79c --- /dev/null +++ b/tests/auto/blackbox/testdata/baseProperties/main.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef FROM_FOO +#error FROM_FOO missing! +#endif +#ifndef FROM_BAR +#error FROM_BAR missing! +#endif +#ifndef FROM_PRJ +#error FROM_PRJ missing! +#endif + +int main() +{ + return 0; +} + diff --git a/tests/auto/blackbox/testdata/baseProperties/prj.qbs b/tests/auto/blackbox/testdata/baseProperties/prj.qbs new file mode 100644 index 000000000..a43b930dc --- /dev/null +++ b/tests/auto/blackbox/testdata/baseProperties/prj.qbs @@ -0,0 +1,10 @@ +import qbs 1.0 +import "imports/Foo.qbs" as Foo + +Project { + Foo { + cpp.defines: base.concat(["FROM_PRJ"]); + files: "main.cpp" + } +} + diff --git a/tests/auto/blackbox/testdata/dynamicLibs/lib1.cpp b/tests/auto/blackbox/testdata/dynamicLibs/lib1.cpp new file mode 100644 index 000000000..0cca8b6e9 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/lib1.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> + +#if defined(_WIN32) || defined(WIN32) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) +#else +# define EXPORT +# define IMPORT +#endif + +IMPORT void lib2_hello(); + +EXPORT int lib1_hello() +{ + puts("lib1 says hello!"); + lib2_hello(); + return 0; +} diff --git a/tests/auto/blackbox/testdata/dynamicLibs/lib2.cpp b/tests/auto/blackbox/testdata/dynamicLibs/lib2.cpp new file mode 100644 index 000000000..26ab80cc7 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/lib2.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> + +#if defined(_WIN32) || defined(WIN32) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) +#else +# define EXPORT __attribute__((visibility("default"))) +# define IMPORT +#endif + +IMPORT void lib3_hello(); + +EXPORT void lib2_hello() +{ + puts("lib2 says hello!"); + lib3_hello(); +} + diff --git a/tests/auto/blackbox/testdata/dynamicLibs/lib3.cpp b/tests/auto/blackbox/testdata/dynamicLibs/lib3.cpp new file mode 100644 index 000000000..4f46512d7 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/lib3.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> + +#if defined(_WIN32) || defined(WIN32) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) +#else +# define EXPORT __attribute__((visibility("default"))) +# define IMPORT +#endif + +EXPORT void lib3_hello() +{ + puts("lib3 says hello!"); +} + +EXPORT char* lib3_greeting() +{ + static char greeting[] = "hello"; + return greeting; +} + diff --git a/tests/auto/blackbox/testdata/dynamicLibs/lib4.cpp b/tests/auto/blackbox/testdata/dynamicLibs/lib4.cpp new file mode 100644 index 000000000..c0ead4721 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/lib4.cpp @@ -0,0 +1,15 @@ +#include "lib4.h" + +TestMe::TestMe() +{ +} + +void TestMe::hello1() const +{ + puts("lib4 says hello!"); +} + +void TestMe::hello2Impl() const +{ + puts("lib4 says hello inline!"); +} diff --git a/tests/auto/blackbox/testdata/dynamicLibs/lib4.h b/tests/auto/blackbox/testdata/dynamicLibs/lib4.h new file mode 100644 index 000000000..689e8d146 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/lib4.h @@ -0,0 +1,26 @@ +#ifndef LIB4_H +#define LIB4_H +#include <stdio.h> + +#ifdef TEST_LIB +# if defined(_WIN32) || defined(WIN32) +# define LIB_EXPORT __declspec(dllexport) +# define LIB_NO_EXPORT +# else +# define LIB_EXPORT __attribute__((visibility("default"))) +# endif +#else +# define LIB_EXPORT +#endif + +class LIB_EXPORT TestMe +{ +public: + TestMe(); + void hello1() const; + inline void hello2() const { hello2Impl(); } +private: + void hello2Impl() const; +}; + +#endif // LIB4_H diff --git a/tests/auto/blackbox/testdata/dynamicLibs/link_dynamiclib.qbs b/tests/auto/blackbox/testdata/dynamicLibs/link_dynamiclib.qbs new file mode 100644 index 000000000..53cebc4a9 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/link_dynamiclib.qbs @@ -0,0 +1,62 @@ +import qbs 1.0 + +Project { + Application { + name : "HelloWorld" + destinationDirectory: "bin" + Group { + files : [ "main.cpp" ] + } + Depends { name: "cpp" } + Depends { name: "lib1" } + Depends { name: "lib4" } + } + + DynamicLibrary { + name : "lib1" + destinationDirectory: "bin" + Group { + files : [ "lib1.cpp" ] + } + Depends { name: "cpp" } + Depends { name: "lib2" } + } + + DynamicLibrary { + name : "lib2" + destinationDirectory: "bin" + cpp.visibility: 'default' + Group { + files : [ "lib2.cpp" ] + } + Depends { name: "cpp" } + Depends { name: "lib3" } + } + + DynamicLibrary { + name : "lib3" + destinationDirectory: "bin" + cpp.visibility: 'hidden' + Group { + files : [ "lib3.cpp" ] + } + Depends { name: "cpp" } + } + + DynamicLibrary { + name : "lib4" + destinationDirectory: "bin" + cpp.visibility: 'hiddenInlines' + cpp.defines: "TEST_LIB" + Group { + files : [ "lib4.h", "lib4.cpp" ] + } + Depends { name: "cpp" } + + Export { + Depends { name: "cpp" } + cpp.includePaths: ['.'] + } + } +} + diff --git a/tests/auto/blackbox/testdata/dynamicLibs/main.cpp b/tests/auto/blackbox/testdata/dynamicLibs/main.cpp new file mode 100644 index 000000000..ea0be27c8 --- /dev/null +++ b/tests/auto/blackbox/testdata/dynamicLibs/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> +#include <lib4.h> + +#if defined(_WIN32) || defined(WIN32) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) +#else +# define EXPORT +# define IMPORT +#endif + +IMPORT int lib1_hello(); + +int main() +{ + puts("application says hello!"); + TestMe test; + test.hello1(); + test.hello2(); + return lib1_hello(); +} + diff --git a/tests/auto/blackbox/testdata/inheritQbsSearchPaths/imports/Foo.qbs b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/imports/Foo.qbs new file mode 100644 index 000000000..f6c1733b5 --- /dev/null +++ b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/imports/Foo.qbs @@ -0,0 +1,7 @@ +import qbs 1.0 + +Product { + type: "application" + Depends { name: 'bli' } +} + diff --git a/tests/auto/blackbox/testdata/inheritQbsSearchPaths/main.cpp b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/main.cpp new file mode 100644 index 000000000..7382cd2dd --- /dev/null +++ b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/main.cpp @@ -0,0 +1,9 @@ +#ifndef HAVE_BLI +#error HAVE_BLI missing! +#endif + +int main() +{ + return 0; +} + diff --git a/tests/auto/blackbox/testdata/inheritQbsSearchPaths/prj.qbs b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/prj.qbs new file mode 100644 index 000000000..ba8284f4f --- /dev/null +++ b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/prj.qbs @@ -0,0 +1,10 @@ +import qbs 1.0 +import "imports/Foo.qbs" as Foo + +Project { + qbsSearchPaths: "subdir" + Foo { + files: "main.cpp" + } +} + diff --git a/tests/auto/blackbox/testdata/inheritQbsSearchPaths/subdir/modules/bli/m.qbs b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/subdir/modules/bli/m.qbs new file mode 100644 index 000000000..b4b93678a --- /dev/null +++ b/tests/auto/blackbox/testdata/inheritQbsSearchPaths/subdir/modules/bli/m.qbs @@ -0,0 +1,7 @@ +import qbs 1.0 + +Module { + Depends {name : "cpp" } + cpp.defines: ["HAVE_BLI"] +} + diff --git a/tests/auto/blackbox/testdata/proper quoting/main.cpp b/tests/auto/blackbox/testdata/proper quoting/main.cpp new file mode 100644 index 000000000..26e0cdc49 --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/main.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> + +#define __stringify__(x) #x +#define stringify(x) __stringify__(x) + +int bla(); + +int main() +{ + printf(DEFINE"\n"); + printf(DEFINEWITHSPACE"\n"); + printf(DEFINEWITHTAB"\n"); + printf(DEFINEWITHBACKSLASH"\n"); + printf(stringify(DEFINEWITHBACKSLASHRAW)"\n"); + + return bla(); +} + diff --git a/tests/auto/blackbox/testdata/proper quoting/my static lib helper.cpp b/tests/auto/blackbox/testdata/proper quoting/my static lib helper.cpp new file mode 100644 index 000000000..76a6a38e9 --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/my static lib helper.cpp @@ -0,0 +1,5 @@ +int helper_function() +{ + return 156; +} + diff --git a/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp b/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp new file mode 100644 index 000000000..c346a6846 --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> +#include <some helper.h> + +int bla() +{ + int n = getSomeNumber(); + printf("Hello World! The magic number is %d.", n); + return n; +} diff --git a/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs b/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs new file mode 100644 index 000000000..64a35b46b --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs @@ -0,0 +1,43 @@ +import qbs 1.0 + +Project { + Product { + type: "application" + name: "Hello World" + files : [ "main.cpp" ] + Depends { name: "cpp" } + Depends { name: "my static lib" } + cpp.defines: [ + 'DEFINE="whitespaceless"', + 'DEFINEWITHSPACE="contains space"', + 'DEFINEWITHTAB="contains\ttab"', + 'DEFINEWITHBACKSLASH="backslash\\\\"', + 'DEFINEWITHBACKSLASHRAW=backslash\\\\' + ] +// cpp.responseFileThreshold: 0 + } + + Product { + type: "staticlibrary" + name : "my static lib" + files : [ "my static lib.cpp" ] + Depends { name: "cpp" } + Depends { name: "helper lib" } +// cpp.responseFileThreshold: 0 + } + + Product { + type: "staticlibrary" + name : "helper lib" + files : [ + "some helper/some helper.h", + "some helper/some helper.cpp" + ] + Depends { name: "cpp" } + Export { + Depends { name: "cpp" } + cpp.includePaths: ['some helper'] + } +// cpp.responseFileThreshold: 0 + } +} diff --git a/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.cpp b/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.cpp new file mode 100644 index 000000000..dcdc7349b --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "some helper.h" + +int getSomeNumber() +{ + return 156; +} + diff --git a/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.h b/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.h new file mode 100644 index 000000000..fe13c76c4 --- /dev/null +++ b/tests/auto/blackbox/testdata/proper quoting/some helper/some helper.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef HELPER_H +#define HELPER_H + +extern int getSomeNumber(); + +#endif + diff --git a/tests/auto/blackbox/testdata/propertiesBlocks/main.cpp b/tests/auto/blackbox/testdata/propertiesBlocks/main.cpp new file mode 100644 index 000000000..0ddce8345 --- /dev/null +++ b/tests/auto/blackbox/testdata/propertiesBlocks/main.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <stdio.h> + +#ifndef HAVE_MAIN_CPP +# error missing define HAVE_MAIN_CPP +#endif +#ifndef DEFINE_IN_PROPERTIES +# error missing define DEFINE_IN_PROPERTIES +#endif + +int main() +{ +#ifdef _DEBUG + puts("Hello World! (debug version)"); +#else + puts("Hello World! (release version)"); +#endif +} + diff --git a/tests/auto/blackbox/testdata/propertiesBlocks/propertiesblocks.qbs b/tests/auto/blackbox/testdata/propertiesBlocks/propertiesblocks.qbs new file mode 100644 index 000000000..5fe02a103 --- /dev/null +++ b/tests/auto/blackbox/testdata/propertiesBlocks/propertiesblocks.qbs @@ -0,0 +1,28 @@ +import qbs 1.0 + +Product { + Depends { name: 'cpp' } + + Properties { + condition: true + type: 'application' + name: 'HelloWorld' + } + + Properties { + condition: name == 'HelloWorld' + cpp.defines: ['DEFINE_IN_PROPERTIES'] + } + + Properties { + condition: qbs.targetOS.contains("weird") + cpp.staticLibraries: "abc" + } + + Group { + cpp.defines: outer.concat(['HAVE_MAIN_CPP', cpp.debugInformation ? '_DEBUG' : '_RELEASE']) + files: ['main.cpp'] + } +} + + diff --git a/tests/auto/blackbox/testdata/transformers/main.cpp b/tests/auto/blackbox/testdata/transformers/main.cpp new file mode 100644 index 000000000..b7ce4f10f --- /dev/null +++ b/tests/auto/blackbox/testdata/transformers/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <string> +#include <iostream> +#include <fstream> + +using namespace std; + +bool displayTextFile(const string &dirPath, const string &fileName) +{ + string fullPath = dirPath + fileName; + ifstream istream(fullPath.c_str()); + if (!istream.is_open()) { + cout << "Cannot open " << fileName << endl; + return false; + } + cout << "---" << fileName << "---" << endl; + char buf[256]; + unsigned int i = 1; + while (istream.good()) { + istream.getline(buf, sizeof(buf)); + cout << i++ << ": " << buf << endl; + } + return true; +} + +int main(int, char **argv) +{ + string appPath(argv[0]); + size_t i = appPath.find_last_of('/'); + if (i == string::npos) + i = appPath.find_last_of('\\'); + if (i == string::npos) // No path, plain executable was called + appPath.clear(); + else + appPath.resize(i + 1); + if (!displayTextFile(appPath, "foo.txt")) + return 1; + if (!displayTextFile(appPath, "bar.txt")) + return 2; + cout << "-------------" << endl; + return 0; +} + diff --git a/tests/auto/blackbox/testdata/transformers/transformers.qbs b/tests/auto/blackbox/testdata/transformers/transformers.qbs new file mode 100644 index 000000000..7445bea15 --- /dev/null +++ b/tests/auto/blackbox/testdata/transformers/transformers.qbs @@ -0,0 +1,86 @@ +import qbs 1.0 +import qbs.File +import qbs.TextFile +import qbs.Xml +import qbs.FileInfo + +Project { + Product { + name: "HelloWorld" + type: "application" + files: ["main.cpp"] + + Depends { name: "cpp" } + + Transformer { + // no inputs -> just a generator + Artifact { + fileName: "foo.txt" + fileTags: "text" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating foo.txt"; + cmd.highlight = "linker"; + cmd.sourceCode = function () { + File.remove(output.fileName); + var f = new TextFile(output.fileName, TextFile.WriteOnly); + f.write("Dear Sir/Madam,\n\n"); + f.write("this is a generated file.\n\n\n"); + f.write("Best Regards and Mellow Greetings,\nYour Build Tool.\n"); + f.close(); + } + return cmd; + } + } + + Transformer { + // no inputs -> just a generator + Artifact { + fileName: "foo.xml" + fileTags: "xml" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating foo.xml"; + cmd.highlight = "linker"; + cmd.sourceCode = function () { + File.remove(output.fileName); + var doc = new XmlDomDocument(); + var root = doc.createElement("root"); + doc.appendChild(root); + + var tag = doc.createElement("Greeting"); + root.appendChild(tag); + tag.appendChild(doc.createTextNode("text node")); + doc.save(output.fileName); + } + return cmd; + } + } + + Transformer { + inputs: ["main.cpp"] // will be taken from the source dir + Artifact { + fileName: "bar.txt" + fileTags: "text" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating bar.txt"; + cmd.highlight = "linker"; + cmd.inputFileName = input.fileName; + cmd.sourceCode = function() { + File.remove(output.fileName); + var f = new TextFile(output.fileName, TextFile.WriteOnly); + f.write("Dear Sir/Madam,\n\n"); + f.write("this file was generated from " + inputFileName + ".\n\n\n"); + f.write("Best Regards and Mellow Greetings,\nYour Build Tool.\n"); + f.close(); + } + return cmd; + } + } + } +} + diff --git a/tests/auto/blackbox/testdata/uic/bla.cpp b/tests/auto/blackbox/testdata/uic/bla.cpp new file mode 100644 index 000000000..b11cb9b43 --- /dev/null +++ b/tests/auto/blackbox/testdata/uic/bla.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "bla.h" + +int main() +{ + Ui::MainWindow mainWindow; + Q_UNUSED(mainWindow); +} + diff --git a/tests/auto/blackbox/testdata/uic/bla.h b/tests/auto/blackbox/testdata/uic/bla.h new file mode 100644 index 000000000..6c3a7d3a5 --- /dev/null +++ b/tests/auto/blackbox/testdata/uic/bla.h @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ui.h" diff --git a/tests/auto/blackbox/testdata/uic/ui.h b/tests/auto/blackbox/testdata/uic/ui.h new file mode 100644 index 000000000..a6898c2c6 --- /dev/null +++ b/tests/auto/blackbox/testdata/uic/ui.h @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ui_ui.h" diff --git a/tests/auto/blackbox/testdata/uic/ui.ui b/tests/auto/blackbox/testdata/uic/ui.ui new file mode 100644 index 000000000..b07f62d05 --- /dev/null +++ b/tests/auto/blackbox/testdata/uic/ui.ui @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"/> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>25</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/blackbox/testdata/uic/uic.qbs b/tests/auto/blackbox/testdata/uic/uic.qbs new file mode 100644 index 000000000..cea4ec2a1 --- /dev/null +++ b/tests/auto/blackbox/testdata/uic/uic.qbs @@ -0,0 +1,17 @@ +import qbs 1.0 + +Project { + Product { + type: "application" + name: "ui" + + Depends { name: "Qt.gui"} + + files: [ + "bla.cpp", + "bla.h", + "ui.ui", + "ui.h" + ] + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index a78b68711..0d378259f 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -190,6 +190,12 @@ void TestBlackbox::initTestCase() ccp(testSourceDir, testDataDir); } +void TestBlackbox::baseProperties() +{ + QDir::setCurrent(testDataDir + QLatin1String("/baseProperties")); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::build_project_data() { QTest::addColumn<QString>("projectSubDir"); @@ -884,6 +890,18 @@ void TestBlackbox::trackRemoveProduct() QVERIFY(!m_qbsStdout.contains("linking product3")); } +void TestBlackbox::transformers() +{ + QDir::setCurrent(testDataDir + "/transformers"); + QCOMPARE(runQbs(), 0); +} + +void TestBlackbox::uic() +{ + QDir::setCurrent(testDataDir + "/uic"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::wildcardRenaming() { QDir::setCurrent(testDataDir + "/wildcard_renaming"); @@ -1149,6 +1167,12 @@ void TestBlackbox::disabledProject() QCOMPARE(runQbs(), 0); } +void TestBlackbox::dynamicLibs() +{ + QDir::setCurrent(testDataDir + "/dynamicLibs"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::explicitlyDependsOn() { QDir::setCurrent(testDataDir + "/explicitlyDependsOn"); @@ -1272,6 +1296,30 @@ void TestBlackbox::jsExtensionsTextFile() QCOMPARE(lines.at(4).trimmed().constData(), "true"); } +void TestBlackbox::inheritQbsSearchPaths() +{ + QDir::setCurrent(testDataDir + "/inheritQbsSearchPaths"); + QCOMPARE(runQbs(), 0); +} + +void TestBlackbox::properQuoting() +{ + QDir::setCurrent(testDataDir + "/proper quoting"); + QCOMPARE(runQbs(), 0); + QbsRunParameters params(QStringList() << "run" << "-qp" << "Hello World"); + params.expectFailure = true; // Because the exit code is non-zero. + QCOMPARE(runQbs(params), 156); + const char * const expectedOutput = "whitespaceless\ncontains space\ncontains\ttab\n" + "backslash\\\nbackslash\\\nHello World! The magic number is 156."; + QCOMPARE(unifiedLineEndings(m_qbsStdout).constData(), expectedOutput); +} + +void TestBlackbox::propertiesBlocks() +{ + QDir::setCurrent(testDataDir + "/propertiesBlocks"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::installedApp() { QDir::setCurrent(testDataDir + "/installed_artifact"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 6d4770d34..c9a5d975b 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -93,6 +93,7 @@ public slots: void initTestCase(); private slots: + void baseProperties(); void build_project_data(); void build_project(); void build_project_dry_run_data(); @@ -100,12 +101,16 @@ private slots: void dependenciesProperty(); void disabledProduct(); void disabledProject(); + void dynamicLibs(); void explicitlyDependsOn(); void fileDependencies(); void jsExtensionsFile(); void jsExtensionsFileInfo(); void jsExtensionsProcess(); void jsExtensionsTextFile(); + void inheritQbsSearchPaths(); + void properQuoting(); + void propertiesBlocks(); void resolve_project_data(); void resolve_project(); void resolve_project_dry_run_data(); @@ -125,6 +130,8 @@ private slots: void trackAddMocInclude(); void trackAddProduct(); void trackRemoveProduct(); + void transformers(); + void uic(); void wildcardRenaming(); void recursiveRenaming(); void recursiveWildcards(); |