[QBS] Autotest runner and Qt plugin path

Jake Petroules Jake.Petroules at qt.io
Sun Jun 19 09:38:10 CEST 2016

AutotestRunner (https://doc.qt.io/qbs/autotestrunner-item.html) provides an environment property that you can use to control the environment that your tests are run with. Create an item derived from AutotestRunner, like so:

AutotestRunner {
    Depends { name: "Qt.core" }
    environment: base.concat(["QT_PLUGIN_PATH=" + Qt.core.pluginPath])

...and then use that in place of AutotestRunner. In fact, I'd argue that we should provide this by default in qbs as "QtAutotestRunner", so maybe look for that in a future release. :)

Good luck!

On Jun 19, 2016, at 12:23 AM, Ch'Gans <chgans at gna.org<mailto:chgans at gna.org>> wrote:

Hi there,

I'm using the Autorunner for my project to run my automated unit tests.
I am using multi QBS profile  (Qt version/toolchains) with no default profile.

When using QtCreator on my dev machine to run my autotests everything
is fine, when using qbs command line within my CI system the tests
fail because of the app being unable unable to find the required Qt
My command looks like: qbs build -p autotest-runner profile:qt57-lnxgcc53_64

One way to solve this on CI is to export QT_QPA_PLATFORM_PLUGIN_PATH
in the shell before running Qbs, something I don't want to do since
the plugin path depends on the profile and i want to use a clean and
predictable shell env. (Note: exporting QTDIR didn't do the trick)

I have tried to use 'qbs.setupBuildEnvironment: {
Environment.putEnv('QT_QPA_PLATFORM_PLUGIN_PATH', Qt.core.pluginPath);
}' inside my product definition, but then Qbs complains that it cannot
find the variable 'Qt'.

Ideally i would like a simple solution that work out of the box. I
don't want to go with qt.conf or the likes.

So my question is: What is the best way to build/setup my
autotest-runner environment so that it can load Qt plugins correctly?

* CI doesn't have an XServer runniing, so i'm trying to use the
'offscreen' platform plugin, anyway this is not the source of my
problem, since by default the testapp try to load xcb and it doesn't
work for the reason explained above
* my test application's rpath contains
"/path/to/qt/unifed/5.X/gcc_64/lib" where 5.X correspond to the Qt
version defined for the Qbs profile in use.
* For now I'm only dealing with Linux, but later I would like to exec
my tests on Windows, and eventually on MacOSX too.

Thanks in advance for any information that could shed some light on
how to achieve that 'the right way' (tm) with Qbs,
QBS mailing list
QBS at qt-project.org<mailto:QBS at qt-project.org>

Jake Petroules - jake.petroules at qt.io<mailto:jake.petroules at qt.io>
Consulting Services Engineer - The Qt Company
Qbs build system evangelist - qbs.io<http://qbs.io>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20160619/676e80ef/attachment.html>

More information about the Qbs mailing list