Skip to content

Commit cee0b56

Browse files
committed
build: build app tests by default
Build app tests by default when GUI support is enabled, while retaining the explicit BUILD_APP_TESTS opt-out. Build and run the app tests in the depends CI job, use the minimal QPA platform, and import the static Qt minimal and QML plugins needed by the test binaries.
1 parent e7e68f9 commit cee0b56

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

.github/workflows/artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: MacOS Install Deps
3131
if: contains(matrix.os, 'macos')
3232
run: |
33-
brew install ccache boost pkgconf libevent qt@6 qrencode coreutils llvm
33+
brew install ccache boost pkgconf qt@6 qrencode coreutils llvm
3434
llvm_prefix="$(brew --prefix llvm)"
3535
echo "CC=${llvm_prefix}/bin/clang" >> "$GITHUB_ENV"
3636
echo "CXX=${llvm_prefix}/bin/clang++" >> "$GITHUB_ENV"

.github/workflows/depends-build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ jobs:
143143
cmake -S . -B "${BUILD_DIR}" -G Ninja \
144144
-DCMAKE_BUILD_TYPE=Release \
145145
-DCMAKE_TOOLCHAIN_FILE="${PWD}/bitcoin/depends/${HOST}/toolchain.cmake" \
146-
-DBUILD_APP_TESTS=OFF \
146+
-DBUILD_APP_TESTS=ON \
147147
-DBUILD_GUI=ON \
148148
-DENABLE_WALLET=ON \
149149
-DENABLE_IPC=OFF
150150
151-
- name: Build bitcoin-core-app
151+
- name: Build
152152
run: |
153-
cmake --build "${BUILD_DIR}" --target bitcoin-core-app --parallel "${JOBS}"
153+
cmake --build "${BUILD_DIR}" --parallel "${JOBS}"
154+
155+
- name: Run app tests
156+
run: |
157+
ctest --test-dir "${BUILD_DIR}" --output-on-failure --parallel "${JOBS}"
154158
155159
- name: Upload depends logs
156160
uses: actions/upload-artifact@v4

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ project(BitcoinCoreApp
66
LANGUAGES CXX
77
)
88

9+
include(CMakeDependentOption)
10+
911
# Language setup
1012
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
1113
# We do not use the install_name_tool when cross-compiling for macOS.
@@ -53,6 +55,7 @@ set(USE_QRCODE TRUE)
5355
# We need this libraries, can ignore the executable bitcoin-qt
5456
set(BUILD_GUI ON)
5557
set(ENABLE_WALLET ON)
58+
cmake_dependent_option(BUILD_APP_TESTS "Build tests for the app" ON "BUILD_GUI" OFF)
5659

5760
# Bitcoin Core codebase
5861
# Builds libraries: univalue, core_interface, bitcoin_node, bitcoin_wallet
@@ -193,7 +196,6 @@ target_link_libraries(bitcoin-core-app
193196
)
194197
qt6_import_qml_plugins(bitcoin-core-app)
195198

196-
option(BUILD_APP_TESTS "Build unit tests for the app" OFF)
197199
if(BUILD_APP_TESTS)
198200
include(CTest)
199201
enable_testing()

test/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ target_link_libraries(bitcoinqml_unit_tests
7272
Qt6::Widgets
7373
)
7474

75-
add_test(NAME bitcoinqml_unit_tests COMMAND bitcoinqml_unit_tests -platform offscreen)
75+
add_test(NAME bitcoinqml_unit_tests COMMAND bitcoinqml_unit_tests -platform minimal)
7676

7777
qt6_add_resources(QMLTESTS_QRC_CPP ${QML_QRC} qml/bitcoin_qmltests.qrc)
7878

@@ -103,4 +103,19 @@ target_include_directories(bitcoinqml_qmltests
103103
${CMAKE_CURRENT_SOURCE_DIR}/..
104104
)
105105

106-
add_test(NAME bitcoinqml_qmltests COMMAND bitcoinqml_qmltests -platform offscreen)
106+
add_test(NAME bitcoinqml_qmltests COMMAND bitcoinqml_qmltests -platform minimal)
107+
108+
get_target_property(qt_lib_type Qt6::Core TYPE)
109+
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
110+
qt6_import_plugins(bitcoinqml_unit_tests INCLUDE Qt6::QMinimalIntegrationPlugin)
111+
qt6_import_plugins(bitcoinqml_qmltests INCLUDE Qt6::QMinimalIntegrationPlugin)
112+
qt6_import_qml_plugins(bitcoinqml_qmltests)
113+
target_link_libraries(bitcoinqml_qmltests PRIVATE
114+
Qt6::qtquickdialogsplugin
115+
)
116+
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.5)
117+
target_link_libraries(bitcoinqml_qmltests PRIVATE Qt6::qtqmlcoreplugin)
118+
else()
119+
target_link_libraries(bitcoinqml_qmltests PRIVATE Qt6::qmlsettingsplugin)
120+
endif()
121+
endif()

0 commit comments

Comments
 (0)