meta-qt6/recipes-qt/qt6/qt6-ptest.inc
Samuli Piippo 8c8ec98428 ptest: include possible test plugins and qml modules
Some of the Qt modules have separate test plugins and qml modules
that are used in the auto tests.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-138066
Change-Id: I00c41396b59f1b380696bbab3489bd93b4a65cc5
Reviewed-by: Ari Parkkila <ari.parkkila@qt.io>
2025-08-18 11:09:51 +00:00

106 lines
3.4 KiB
PHP

FILESEXTRAPATHS:append := ":${THISDIR}/ptest"
SRC_URI += "file://run-ptest"
inherit ptest
QT_PTEST_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '1', '0', d)}"
PTEST_ENABLED = "${QT_PTEST_ENABLED}"
DEBUG_PREFIX_MAP += "\
-fmacro-prefix-map=${D}= \
"
do_install_ptest_base[progress] = "${@d.getVarFlag('do_compile', 'progress')}"
B_PTEST = "${WORKDIR}/build-ptest"
fakeroot do_install_ptest() {
cat >${WORKDIR}/toolchain-ptest.cmake <<EOF
include(${WORKDIR}/toolchain.cmake)
list(PREPEND CMAKE_FIND_ROOT_PATH ${D})
EOF
mkdir -p ${B_PTEST}
cd ${B_PTEST}
cmake \
${OECMAKE_GENERATOR_ARGS} \
-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-ptest.cmake \
-DPython3_EXECUTABLE=${PYTHON} \
${EXTRA_OECMAKE} \
-DQT_BUILD_STANDALONE_TESTS=ON \
-DQT_BUILD_EXAMPLES=OFF \
-DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${D}${prefix} \
-DCMAKE_STAGING_PREFIX=${D}${prefix} \
-DCMAKE_SKIP_RPATH=ON \
-DQT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES=ON \
-DQT_FORCE_BUILTIN_TESTDATA=ON \
${S} \
-Wno-dev
${CMAKE_VERBOSE} cmake --build ${B_PTEST} --target all
for tests in auto baseline
do
if [ -e "${B_PTEST}/tests/$tests" ]; then
install -d ${D}${PTEST_PATH}/tests
find ${B_PTEST}/tests/$tests ! -type d -a \( \
-executable -o \
-name qmldir -o \
-name *.rcc \
\) -exec sh -c '\
install -D "$1" "${D}${PTEST_PATH}${1#${B_PTEST}}" \
' _ {} \;
fi
done
if [ -e "${B_PTEST}/${baselib}" ]; then
find ${B_PTEST}/${baselib} \
! -type d -a \( -executable -o -name qmldir \) \
-exec sh -c '\
install -D "$1" "${D}${PTEST_PATH}${1#${B_PTEST}/${baselib}}" \
' _ {} \;
fi
}
fakeroot python do_create_ptest_list() {
import json, os, subprocess
builddir = d.getVar('B_PTEST')
ptest_path = d.getVar('PTEST_PATH')
try:
command_output = subprocess.check_output(['ctest', '--show-only=json-v1'], cwd=builddir, text=True)
except subprocess.CalledProcessError as e:
bb.fatal('Could not get list of tests: {e.output}')
json_data = json.loads(command_output)
tests_data = json_data.get('tests', [])
output = d.getVar('D') + os.path.join(ptest_path, 'tst_list')
file = open(output, 'w')
for test in tests_data:
test_name = test.get('name')
working_directory = next((prop['value'] for prop in test.get('properties', []) if prop['name'] == 'WORKING_DIRECTORY'), None)
test_executable = os.path.normpath(os.path.join(working_directory,test_name))
if test_executable.startswith(builddir) and os.path.isfile(test_executable):
test_executable = test_executable.replace(builddir,ptest_path)
file.write(f'{test_executable}\n')
file.close()
}
addtask create_ptest_list after do_install_ptest_base before do_package
python () {
if not(d.getVar('PTEST_ENABLED') == "1"):
bb.build.deltask('do_create_ptest_list', d)
}
INSANE_SKIP:${PN}-ptest += "file-rdeps"
PACKAGESPLITFUNCS =+ "remove_ptest_debug"
remove_ptest_debug() {
if [ -e ${PKGD}${QT6_INSTALL_LIBDIR}/${BPN}/ptest ]; then
find ${PKGD}${QT6_INSTALL_LIBDIR}/${BPN}/ptest -depth -type d -name .debug -exec rm -rf '{}' \;
fi
}