diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-09-22 13:14:00 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-09-25 11:36:58 +0000 |
commit | e3695fef9c4bbdf4a2c8721bca453cf908172e67 (patch) | |
tree | eba67a461405585eff4f990d60462b88bb4dc904 | |
parent | 8b6426a5af4a7b397d8ed3bb799902d281ea6984 (diff) |
Use full product names in command line frontend
Fixes: QBS-1207
Change-Id: I92cbca8d2842e843670f27a358b19dfe6006afbc
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r-- | src/app/qbs/commandlinefrontend.cpp | 18 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/run-multiplexed/main.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs | 21 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 19 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
5 files changed, 48 insertions, 12 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp index 701a49046..4248f55a7 100644 --- a/src/app/qbs/commandlinefrontend.cpp +++ b/src/app/qbs/commandlinefrontend.cpp @@ -354,8 +354,8 @@ CommandLineFrontend::ProductMap CommandLineFrontend::productsToUse() const QList<ProductData> &productList = products[project]; const ProjectData projectData = project.projectData(); for (const ProductData &product : projectData.allProducts()) { - productNames << product.name(); - if (useAll || m_parser.products().contains(product.name())) { + productNames << product.fullDisplayName(); + if (useAll || m_parser.products().contains(product.fullDisplayName())) { productList.push_back(product); } } @@ -566,7 +566,7 @@ int CommandLineFrontend::runTarget() const QString executableFilePath = productToRun.targetExecutable(); if (executableFilePath.isEmpty()) { throw ErrorInfo(Tr::tr("Cannot run: Product '%1' is not an application.") - .arg(productToRun.name())); + .arg(productToRun.fullDisplayName())); } RunEnvironment runEnvironment = m_projects.front().getRunEnvironment(productToRun, m_parser.installOptions(m_projects.front().profile()), @@ -649,7 +649,7 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() if (m_parser.products().size() == 1) { for (const ProductData &p : m_projects.front().projectData().allProducts()) { - if (p.name() == m_parser.products().constFirst()) + if (p.fullDisplayName() == m_parser.products().constFirst()) return p; } QBS_CHECK(false); @@ -673,14 +673,8 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() ErrorInfo error(Tr::tr("Ambiguous use of command '%1': No product given, but project " "has more than one runnable product.").arg(m_parser.commandName())); error.append(Tr::tr("Use the '--products' option with one of the following products:")); - for (const ProductData &p : std::as_const(runnableProducts)) { - QString productRepr = QLatin1String("\t") + p.name(); - if (p.profile() != m_projects.front().profile()) { - productRepr.append(QLatin1String(" [")).append(p.profile()) - .append(QLatin1Char(']')); - } - error.append(productRepr); - } + for (const ProductData &p : std::as_const(runnableProducts)) + error.append(QLatin1String("\t") + p.fullDisplayName()); throw error; } diff --git a/tests/auto/blackbox/testdata/run-multiplexed/main.cpp b/tests/auto/blackbox/testdata/run-multiplexed/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata/run-multiplexed/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs b/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs new file mode 100644 index 000000000..11577b54a --- /dev/null +++ b/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs @@ -0,0 +1,21 @@ +import qbs.Host + +CppApplication { + aggregate: false + consoleApplication: true + name: "app" + multiplexByQbsProperties: "buildVariants" + + qbs.buildVariants: ["debug", "release"] + + files: "main.cpp" + + Probe { + id: checker + property string targetPlatform: qbs.targetPlatform + configure: { + if (targetPlatform !== Host.platform()) + console.info("targetPlatform differs from hostPlatform"); + } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 2befc8db8..f8a037766 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2741,6 +2741,25 @@ void TestBlackbox::ruleWithNonRequiredInputs() QVERIFY2(m_qbsStdout.contains("generating"), m_qbsStdout.constData()); } +void TestBlackbox::runMultiplexed() +{ + QDir::setCurrent(testDataDir + "/run-multiplexed"); + QCOMPARE(runQbs({"resolve"}), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + + QbsRunParameters params("run"); + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + params.arguments = QStringList{"-p", "app"}; + QVERIFY(runQbs(params) != 0); + params.expectFailure = false; + params.arguments.last() = "app {\"buildVariant\":\"debug\"}"; + QCOMPARE(runQbs(params), 0); + params.arguments.last() = "app {\"buildVariant\":\"release\"}"; + QCOMPARE(runQbs(params), 0); +} + void TestBlackbox::sanitizer_data() { QTest::addColumn<QString>("sanitizer"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index e405c3c0e..c662395e3 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -286,6 +286,7 @@ private slots: void ruleCycle(); void ruleWithNoInputs(); void ruleWithNonRequiredInputs(); + void runMultiplexed(); void sanitizer_data(); void sanitizer(); void scannerItem(); |