Fix testdata handling

Make sure to handle glob expressions in the entire path given, not just
the end of the path. This handles tests like qsslkey and qnetworkreply.

Also copy/install the testdata in the final test directory path under
a "testdata" subdir.
Previously INSTALL_TESTDIR was used, which was never set to anything.

Change-Id: I2408e12f586cadeb524ffa249e851a4179324b23
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
This commit is contained in:
Alexandru Croitor 2019-07-26 18:15:41 +02:00
parent e61a7a2c57
commit 1307736c7d
2 changed files with 22 additions and 6 deletions

View File

@ -192,6 +192,11 @@ unset(__config_path_part)
# at the QtPostProcess stage.
set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "")
# Save the value of the current first project source dir.
# This will be /path/to/qtbase for qtbase both in a super-build and a non super-build.
# This will be /path/to/qtbase/tests when building standalone tests.
set(QT_TOP_LEVEL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Functions and macros:
# qt_remove_args can remove arguments from an existing list of function
@ -2145,7 +2150,11 @@ function(add_qt_test name)
endif()
else()
# Install test data
qt_path_join(testdata_install_dir ${QT_INSTALL_DIR} "${INSTALL_TESTDIR}/${name}")
file(RELATIVE_PATH relative_path_to_test_project
"${QT_TOP_LEVEL_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}")
qt_path_join(testdata_install_dir ${QT_INSTALL_DIR}
"${relative_path_to_test_project}/testdata")
foreach(testdata IN LISTS arg_TESTDATA)
set(testdata "${CMAKE_CURRENT_SOURCE_DIR}/${testdata}")
if (IS_DIRECTORY "${testdata}")

View File

@ -31,6 +31,7 @@
from __future__ import annotations
from argparse import ArgumentParser
from textwrap import dedent
import copy
import xml.etree.ElementTree as ET
from itertools import chain
@ -1602,11 +1603,17 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str,
has_test_data = True
cm_fh.write('# Collect test data\n')
for data in test_data:
if data.endswith('*'):
cm_fh.write('{}file(GLOB test_data_glob \n{}LIST_DIRECTORIES'
' true\n{}RELATIVE ${{CMAKE_CURRENT_SOURCE_DIR}}\n{}"{}")\n'\
.format(spaces(indent), spaces(indent + 1), \
spaces(indent + 1), spaces(indent + 1), data))
if '*' in data:
cm_fh.write(dedent("""
{indent}file(GLOB test_data_glob
{indent1}LIST_DIRECTORIES true
{indent1}RELATIVE ${{CMAKE_CURRENT_SOURCE_DIR}}
{indent1}"{}")
""").format(
data,
indent=spaces(indent),
indent1=spaces(indent + 1)
))
cm_fh.write('{}list(APPEND test_data ${{test_data_glob}})\n'.format(spaces(indent)))
else:
cm_fh.write('{}list(APPEND test_data "{}")\n'.format(spaces(indent), data))