Skip to content

Commit

Permalink
fix: Use Qt_QPA_PLATFORM=offscreen for testing
Browse files Browse the repository at this point in the history
Otherwise the tests always popped up new windows, which was very
annoying as they kept grabbing focus on my setup.

Fix #53
  • Loading branch information
LeonMatthesKDAB committed Jul 9, 2024
1 parent 494a62d commit f8c61a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 3rdparty-kdab/mfc-utils
Submodule mfc-utils updated from c59488 to 50062d
2 changes: 1 addition & 1 deletion 3rdparty-kdab/photonwidgets
Submodule photonwidgets updated from a5a3cd to 6df5ec
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function(add_knut_test_variadic name)
target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)

add_test(${name} ${CMAKE_BINARY_DIR}/bin/${name})
set_property(TEST ${name} PROPERTY ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endfunction()

# * Create a test, with one source and arbitrary libs
Expand Down
6 changes: 5 additions & 1 deletion tests/tst_knut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class TestKnut : public QObject
private:
void run_knut(const QStringList &arguments)
{
const int failedTests = QProcess::execute(KNUT_BINARY_PATH, arguments);
QProcess knut;
// Propagate the process environment.
// This allows us to e.g. pass QT_QPA_PLATFORM=offscreen to avoid window popups
knut.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
const int failedTests = knut.execute(KNUT_BINARY_PATH, arguments);

switch (failedTests) {
case -2:
Expand Down

0 comments on commit f8c61a1

Please sign in to comment.