diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-12-11 15:59:24 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-12-13 13:36:22 +0000 |
commit | 7b5349d182bcb4c9d7a3d1501768b91c9fa93fe9 (patch) | |
tree | 7625e9568275056dccac058b283871296366e132 /tests | |
parent | 85cf0b14b7c07334989f74edd1902c3fe200dda8 (diff) |
Fix bogus error about duplicate source files
There is no conflict if the same file is pulled in both as a target
artifact of a module and a normal source file.
Fixes: QBS-1416
Change-Id: Ic7467af5a8728ebb1540381c845ffc0f40e06a9c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
4 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/language/testdata/file-in-product-and-module.qbs b/tests/auto/language/testdata/file-in-product-and-module.qbs new file mode 100644 index 000000000..1cb2fa866 --- /dev/null +++ b/tests/auto/language/testdata/file-in-product-and-module.qbs @@ -0,0 +1,9 @@ +Product { + name: "p" + Depends { name: "module_with_file" } + property bool addFileToProduct + Group { + files: "zort" + condition: addFileToProduct + } +} diff --git a/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs b/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs new file mode 100644 index 000000000..ded81e046 --- /dev/null +++ b/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs @@ -0,0 +1,14 @@ +Module { + property bool file1IsTarget + property bool file2IsTarget + Group { + prefix: product.sourceDirectory + '/' + files: "zort" + filesAreTargets: product.module_with_file.file1IsTarget + } + Group { + prefix: product.sourceDirectory + '/' + files: "zort" + filesAreTargets: product.module_with_file.file2IsTarget + } +} diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index ab5aaf759..fc16ca582 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -1100,6 +1100,54 @@ void TestLanguage::fileContextProperties() QCOMPARE(exceptionCaught, false); } +void TestLanguage::fileInProductAndModule_data() +{ + QTest::addColumn<bool>("file1IsTarget"); + QTest::addColumn<bool>("file2IsTarget"); + QTest::addColumn<bool>("addFileToProduct"); + QTest::addColumn<bool>("successExpected"); + QTest::newRow("file occurs twice in module as non-target") << false << false << false << false; + QTest::newRow("file occurs twice in module as non-target, and in product as well") + << false << false << true << false; + QTest::newRow("file occurs in module as non-target and target") + << false << true << false << true; + QTest::newRow("file occurs in module as non-target and target, and in product as well") + << false << true << true << false; + QTest::newRow("file occurs in module as target and non-target") + << true << false << false << true; + QTest::newRow("file occurs in module as target and non-target, and in product as well") + << true << false << true << false; + QTest::newRow("file occurs twice in module as target") << true << true << false << false; + QTest::newRow("file occurs twice in module as target, and in product as well") + << true << true << true << false; +} + +void TestLanguage::fileInProductAndModule() +{ + bool exceptionCaught = false; + QFETCH(bool, file1IsTarget); + QFETCH(bool, file2IsTarget); + QFETCH(bool, addFileToProduct); + QFETCH(bool, successExpected); + try { + SetupProjectParameters params = defaultParameters; + params.setProjectFilePath(testProject("file-in-product-and-module.qbs")); + params.setOverriddenValues(QVariantMap{ + std::make_pair("modules.module_with_file.file1IsTarget", file1IsTarget), + std::make_pair("modules.module_with_file.file2IsTarget", file2IsTarget), + std::make_pair("products.p.addFileToProduct", addFileToProduct), + }); + project = loader->loadProject(params); + QVERIFY(!!project); + QHash<QString, ResolvedProductPtr> products = productsFromProject(project); + QCOMPARE(products.size(), 1); + } catch (const ErrorInfo &e) { + exceptionCaught = true; + QVERIFY2(e.toString().contains("Duplicate"), qPrintable(e.toString())); + } + QCOMPARE(exceptionCaught, !successExpected); +} + void TestLanguage::getNativeSetting() { bool exceptionCaught = false; diff --git a/tests/auto/language/tst_language.h b/tests/auto/language/tst_language.h index 660c1b9b6..b2d242bfb 100644 --- a/tests/auto/language/tst_language.h +++ b/tests/auto/language/tst_language.h @@ -103,6 +103,8 @@ private slots: void erroneousFiles(); void exports(); void fileContextProperties(); + void fileInProductAndModule_data(); + void fileInProductAndModule(); void fileTags_data(); void fileTags(); void groupConditions_data(); |