diff options
author | Kai Dohmen <psykai1993@googlemail.com> | 2021-10-14 12:58:03 +0200 |
---|---|---|
committer | Kai Dohmen <psykai1993@googlemail.com> | 2021-10-26 12:25:46 +0000 |
commit | 22b93598471a22e09052405ad33e24bd15f1e6be (patch) | |
tree | 45b7fc61d62bab5db5a017e55115e2c661af3800 | |
parent | 24044d6da5d3f3725adc134fdb7e71fe398381ff (diff) | |
download | qbs-22b93598471a22e09052405ad33e24bd15f1e6be.tar.gz |
Print conan output while ConanfileProbe runs
Sometimes installing dependencies with conan takes multiple minutes. To
see what conan does and if somehow conan stopped working the conan
stdout and stderr will be printed to commandline.
Change-Id: I987ef95b38deecd713dc6b46be0e2641025345c6
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
6 files changed, 47 insertions, 7 deletions
diff --git a/doc/reference/items/probe/conanfile-probe.qdoc b/doc/reference/items/probe/conanfile-probe.qdoc index d454839f4..cc91b9237 100644 --- a/doc/reference/items/probe/conanfile-probe.qdoc +++ b/doc/reference/items/probe/conanfile-probe.qdoc @@ -246,3 +246,12 @@ \nodefaultvalue */ + +/*! + \qmlproperty var ConanfileProbe::verbose + + Set to \c{true} to print all output of `conan install`. + If this property is \c{false} only error output will be printed. + + \defaultvalue \c{false} +*/ diff --git a/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs b/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs index cd722933c..03dde25e2 100644 --- a/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs +++ b/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs @@ -43,6 +43,7 @@ Probe { property stringList generators: ["json"] property var options property var settings + property bool verbose: false // Output property var dependencies @@ -104,11 +105,25 @@ Probe { args = args.concat(["-if", generatedFilesPath]); var p = new Process(); - try { - p.exec(executable, args, true); - } finally { + p.start(executable, args); + while (!p.waitForFinished(500)) { + const output = p.readStdOut(); + if (verbose && output) { + console.info(output); + } + } + while (!p.atEnd()) { + const output = p.readStdOut(); + if (verbose && output) { + console.info(output); + } + } + if (p.exitCode()) { + const errorOutput = p.readStdErr(); p.close(); + throw errorOutput; } + p.close(); if (generators.contains("json")) { if (!File.exists(generatedFilesPath + "/conanbuildinfo.json")) diff --git a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs index c1cb1ddda..adcb2bd9c 100644 --- a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs +++ b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs @@ -2,11 +2,12 @@ import qbs.Probes import qbs.TextFile Project { + readonly property bool forceFailure: false Probes.ConanfileProbe { id: conan conanfilePath: path + "/conanfile.py" - options: ({opt: "True"}) + options: ({opt: "True", forceFailure: (project.forceFailure ? "True" : "False")}) settings: ({os: "AIX"}) } diff --git a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py index 630cf0283..59e40cc80 100644 --- a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py +++ b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py @@ -7,12 +7,13 @@ class TestApp(ConanFile): version = "6.6.6" settings = "os" - options = {"opt": [True, False]} - default_options = {"opt": False} + options = {"opt": [True, False], "forceFailure": [True, False]} + default_options = {"opt": False, "forceFailure": False} requires = "testlib/1.2.3@qbs/testing" def configure(self): + assert(not self.options.forceFailure) self.options["testlib"].opt = self.options.opt def source(self): diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 41f307632..c64976e36 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1867,8 +1867,18 @@ void TestBlackbox::cxxLanguageVersion_data() std::make_pair(QString("msvc-new"), QString("/std:"))}); } +void TestBlackbox::conanfileProbe_data() +{ + QTest::addColumn<bool>("forceFailure"); + + QTest::newRow("success") << false; + QTest::newRow("failure") << true; +} + void TestBlackbox::conanfileProbe() { + QFETCH(bool, forceFailure); + QString executable = findExecutable({"conan"}); if (executable.isEmpty()) QSKIP("conan is not installed or not available in PATH."); @@ -1883,7 +1893,10 @@ void TestBlackbox::conanfileProbe() QVERIFY(waitForProcessSuccess(conan)); QDir::setCurrent(testDataDir + "/conanfile-probe/testapp"); - QCOMPARE(runQbs(QbsRunParameters("resolve", {"--force-probe-execution"})), 0); + QCOMPARE(runQbs(QbsRunParameters("resolve", + {"--force-probe-execution", + QStringLiteral("projects.conanfile-probe-project.forceFailure:") + + (forceFailure ? "true" : "false")})), forceFailure ? 1 : 0); QFile file(relativeBuildDir() + "/results.json"); QVERIFY(file.open(QIODevice::ReadOnly)); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 2f443f681..987c87d6a 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -89,6 +89,7 @@ private slots: void conflictingArtifacts(); void cxxLanguageVersion(); void cxxLanguageVersion_data(); + void conanfileProbe_data(); void conanfileProbe(); void cpuFeatures(); void dependenciesProperty(); |