From 453fa4ca39c93f31d496d856babda17b919d6cec Mon Sep 17 00:00:00 2001 From: Luca Di Sera Date: Wed, 10 May 2023 16:29:48 +0200 Subject: QDoc: Move catch_conversions under src MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QDoc employs a very small support library, "catch_conversions", to provide better output for certain types when used with the Catch2 testing framework, which QDoc uses for some of its tests. "catch_conversions" was currently kept under "tests/auto/qdoc" and its headers were included and used directly by its sibling tests by relative paths. Due to a certain restructuring that is happening in QDoc, with one of the goals, among others, being to increase the locality of QDoc-related code under "src/qdoc", the "catch_conversions" support library is now moved under "src/qdoc". To allow code that depended on it to keep their usages without requiring the addition of some relative paths from the "tests" directory to the "src" directory, a library target, "Qt::QDocCatchConversionsPrivate" was created for the support library. The target can be linked-to to gain access to the previously-directly-used headers, with include path "catch_conversions/.*". To allow for this specific include path to work, the internal directory structure for "catch_conversions" was slightly modified with the addition of some intermediate directories in between its root and the library headers. Targets under "tests/auto/qdoc" that used the dependency now link to it instead. Hence, their "CMakeLists.txt" files were modified to avoid using the dependency as an include directory and instead use "Qt::QDocCatchConversionsPrivate" as a library. The inclusions of the of the "catch_conversions" headers in relevant sources was modified to respect the new "catch_conversions/.*" path. The root "CMakeLists.txt" file under "src/qdoc" was modified to add the relevant library as a subdirectory. Change-Id: Iec24ca3877a48a42a55ff406309813aa083ab23f Reviewed-by: Paul Wicking Reviewed-by: Qt CI Bot Reviewed-by: Topi Reiniƶ --- src/qdoc/CMakeLists.txt | 1 + src/qdoc/catch_conversions/CMakeLists.txt | 10 +++++++++ .../src/catch_conversions/qdoc_catch_conversions.h | 24 ++++++++++++++++++++++ .../src/catch_conversions/qt_catch_conversions.h | 19 +++++++++++++++++ .../src/catch_conversions/std_catch_conversions.h | 16 +++++++++++++++ .../catch_conversions/qdoc_catch_conversions.h | 24 ---------------------- .../qdoc/catch_conversions/qt_catch_conversions.h | 19 ----------------- .../qdoc/catch_conversions/std_catch_conversions.h | 16 --------------- .../qdoc/catch_generators/tests/CMakeLists.txt | 2 +- .../tests/generators/catch_path_generator.cpp | 2 +- .../tests/generators/catch_qchar_generator.cpp | 2 +- .../tests/generators/catch_qstring_generator.cpp | 2 +- .../combinators/catch_oneof_generator.cpp | 2 +- tests/auto/qdoc/qdoc/CMakeLists.txt | 2 +- .../boundaries/filesystem/catch_directorypath.cpp | 2 +- .../qdoc/boundaries/filesystem/catch_filepath.cpp | 2 +- .../qdoc/qdoc/filesystem/catch_fileresolver.cpp | 2 +- 17 files changed, 79 insertions(+), 68 deletions(-) create mode 100644 src/qdoc/catch_conversions/CMakeLists.txt create mode 100644 src/qdoc/catch_conversions/src/catch_conversions/qdoc_catch_conversions.h create mode 100644 src/qdoc/catch_conversions/src/catch_conversions/qt_catch_conversions.h create mode 100644 src/qdoc/catch_conversions/src/catch_conversions/std_catch_conversions.h delete mode 100644 tests/auto/qdoc/catch_conversions/qdoc_catch_conversions.h delete mode 100644 tests/auto/qdoc/catch_conversions/qt_catch_conversions.h delete mode 100644 tests/auto/qdoc/catch_conversions/std_catch_conversions.h diff --git a/src/qdoc/CMakeLists.txt b/src/qdoc/CMakeLists.txt index bcd7c46bb..11f947e01 100644 --- a/src/qdoc/CMakeLists.txt +++ b/src/qdoc/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause add_subdirectory(catch) +add_subdirectory(catch_conversions) if(QT_FEATURE_qdoc AND QT_FEATURE_clangcpp) add_subdirectory(qdoc) diff --git a/src/qdoc/catch_conversions/CMakeLists.txt b/src/qdoc/catch_conversions/CMakeLists.txt new file mode 100644 index 000000000..e19514c01 --- /dev/null +++ b/src/qdoc/catch_conversions/CMakeLists.txt @@ -0,0 +1,10 @@ +qt_internal_add_module(QDocCatchConversionsPrivate + HEADER_MODULE + EXTERNAL_HEADERS_DIR src +) + +qt_internal_extend_target(QDocCatchConversionsPrivate + PUBLIC_INCLUDE_DIRECTORIES + $ + $ +) diff --git a/src/qdoc/catch_conversions/src/catch_conversions/qdoc_catch_conversions.h b/src/qdoc/catch_conversions/src/catch_conversions/qdoc_catch_conversions.h new file mode 100644 index 000000000..ef0cb2cef --- /dev/null +++ b/src/qdoc/catch_conversions/src/catch_conversions/qdoc_catch_conversions.h @@ -0,0 +1,24 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "qt_catch_conversions.h" + +#include +#include +#include + +#include + +inline std::ostream& operator<<(std::ostream& os, const DirectoryPath& dirpath) { + return os << dirpath.value().toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const FilePath& filepath) { + return os << filepath.value().toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const ResolvedFile& resolved_file) { + return os << "ResolvedFile{ query: " << resolved_file.get_query().toStdString() << ", " << "filepath: " << resolved_file.get_path() << " }"; +} diff --git a/src/qdoc/catch_conversions/src/catch_conversions/qt_catch_conversions.h b/src/qdoc/catch_conversions/src/catch_conversions/qt_catch_conversions.h new file mode 100644 index 000000000..68abf5fb0 --- /dev/null +++ b/src/qdoc/catch_conversions/src/catch_conversions/qt_catch_conversions.h @@ -0,0 +1,19 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "std_catch_conversions.h" + +#include + +#include +#include + +inline std::ostream& operator<<(std::ostream& os, const QChar& character) { + return os << QString{character}.toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const QString& string) { + return os << string.toStdString(); +} diff --git a/src/qdoc/catch_conversions/src/catch_conversions/std_catch_conversions.h b/src/qdoc/catch_conversions/src/catch_conversions/std_catch_conversions.h new file mode 100644 index 000000000..be8fa65d7 --- /dev/null +++ b/src/qdoc/catch_conversions/src/catch_conversions/std_catch_conversions.h @@ -0,0 +1,16 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include +#include + +template +inline std::ostream& operator<<(std::ostream& os, const std::optional& optional) { + os << "std::optional{\n\t"; + if (optional) os << optional.value(); + else os <<"nullopt"; + + return os << "\n};"; +} diff --git a/tests/auto/qdoc/catch_conversions/qdoc_catch_conversions.h b/tests/auto/qdoc/catch_conversions/qdoc_catch_conversions.h deleted file mode 100644 index ef0cb2cef..000000000 --- a/tests/auto/qdoc/catch_conversions/qdoc_catch_conversions.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "qt_catch_conversions.h" - -#include -#include -#include - -#include - -inline std::ostream& operator<<(std::ostream& os, const DirectoryPath& dirpath) { - return os << dirpath.value().toStdString(); -} - -inline std::ostream& operator<<(std::ostream& os, const FilePath& filepath) { - return os << filepath.value().toStdString(); -} - -inline std::ostream& operator<<(std::ostream& os, const ResolvedFile& resolved_file) { - return os << "ResolvedFile{ query: " << resolved_file.get_query().toStdString() << ", " << "filepath: " << resolved_file.get_path() << " }"; -} diff --git a/tests/auto/qdoc/catch_conversions/qt_catch_conversions.h b/tests/auto/qdoc/catch_conversions/qt_catch_conversions.h deleted file mode 100644 index 68abf5fb0..000000000 --- a/tests/auto/qdoc/catch_conversions/qt_catch_conversions.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "std_catch_conversions.h" - -#include - -#include -#include - -inline std::ostream& operator<<(std::ostream& os, const QChar& character) { - return os << QString{character}.toStdString(); -} - -inline std::ostream& operator<<(std::ostream& os, const QString& string) { - return os << string.toStdString(); -} diff --git a/tests/auto/qdoc/catch_conversions/std_catch_conversions.h b/tests/auto/qdoc/catch_conversions/std_catch_conversions.h deleted file mode 100644 index be8fa65d7..000000000 --- a/tests/auto/qdoc/catch_conversions/std_catch_conversions.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include -#include - -template -inline std::ostream& operator<<(std::ostream& os, const std::optional& optional) { - os << "std::optional{\n\t"; - if (optional) os << optional.value(); - else os <<"nullopt"; - - return os << "\n};"; -} diff --git a/tests/auto/qdoc/catch_generators/tests/CMakeLists.txt b/tests/auto/qdoc/catch_generators/tests/CMakeLists.txt index 240f5ac63..76c366331 100644 --- a/tests/auto/qdoc/catch_generators/tests/CMakeLists.txt +++ b/tests/auto/qdoc/catch_generators/tests/CMakeLists.txt @@ -15,7 +15,7 @@ qt_internal_add_test(tst_QDoc_Catch_Generators utilities/semantics/catch_generator_handler.cpp INCLUDE_DIRECTORIES ../src - ../../catch_conversions LIBRARIES Qt::QDocCatchPrivate + Qt::QDocCatchConversionsPrivate ) diff --git a/tests/auto/qdoc/catch_generators/tests/generators/catch_path_generator.cpp b/tests/auto/qdoc/catch_generators/tests/generators/catch_path_generator.cpp index 71e9e50b4..968008a56 100644 --- a/tests/auto/qdoc/catch_generators/tests/generators/catch_path_generator.cpp +++ b/tests/auto/qdoc/catch_generators/tests/generators/catch_path_generator.cpp @@ -10,7 +10,7 @@ #include "utilities/statistics/distribution.h" #include "utilities/semantics/copy_value.h" -#include +#include #include diff --git a/tests/auto/qdoc/catch_generators/tests/generators/catch_qchar_generator.cpp b/tests/auto/qdoc/catch_generators/tests/generators/catch_qchar_generator.cpp index a072aff88..47ef23364 100644 --- a/tests/auto/qdoc/catch_generators/tests/generators/catch_qchar_generator.cpp +++ b/tests/auto/qdoc/catch_generators/tests/generators/catch_qchar_generator.cpp @@ -4,7 +4,7 @@ #include "namespaces.h" #include "generators/qchar_generator.h" -#include +#include #include diff --git a/tests/auto/qdoc/catch_generators/tests/generators/catch_qstring_generator.cpp b/tests/auto/qdoc/catch_generators/tests/generators/catch_qstring_generator.cpp index e99335dd0..75d7efcf1 100644 --- a/tests/auto/qdoc/catch_generators/tests/generators/catch_qstring_generator.cpp +++ b/tests/auto/qdoc/catch_generators/tests/generators/catch_qstring_generator.cpp @@ -5,7 +5,7 @@ #include "generators/qchar_generator.h" #include "generators/qstring_generator.h" -#include +#include #include diff --git a/tests/auto/qdoc/catch_generators/tests/generators/combinators/catch_oneof_generator.cpp b/tests/auto/qdoc/catch_generators/tests/generators/combinators/catch_oneof_generator.cpp index 191ac9dfe..68e990813 100644 --- a/tests/auto/qdoc/catch_generators/tests/generators/combinators/catch_oneof_generator.cpp +++ b/tests/auto/qdoc/catch_generators/tests/generators/combinators/catch_oneof_generator.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include +#include #include "namespaces.h" #include "generators/k_partition_of_r_generator.h" diff --git a/tests/auto/qdoc/qdoc/CMakeLists.txt b/tests/auto/qdoc/qdoc/CMakeLists.txt index 616139712..925290ecd 100644 --- a/tests/auto/qdoc/qdoc/CMakeLists.txt +++ b/tests/auto/qdoc/qdoc/CMakeLists.txt @@ -16,7 +16,7 @@ qt_internal_add_test(tst_QDoc INCLUDE_DIRECTORIES ${QDOC_INCLUDE_DIRECTORY} ../catch_generators/ - ../catch_conversions/ LIBRARIES Qt::QDocCatchPrivate + Qt::QDocCatchConversionsPrivate ) diff --git a/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_directorypath.cpp b/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_directorypath.cpp index ed31a50ec..5321e2619 100644 --- a/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_directorypath.cpp +++ b/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_directorypath.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include +#include #include diff --git a/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_filepath.cpp b/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_filepath.cpp index 167aafc85..46481e4d6 100644 --- a/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_filepath.cpp +++ b/tests/auto/qdoc/qdoc/boundaries/filesystem/catch_filepath.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include +#include #include diff --git a/tests/auto/qdoc/qdoc/filesystem/catch_fileresolver.cpp b/tests/auto/qdoc/qdoc/filesystem/catch_fileresolver.cpp index 440de7bee..fca33debb 100644 --- a/tests/auto/qdoc/qdoc/filesystem/catch_fileresolver.cpp +++ b/tests/auto/qdoc/qdoc/filesystem/catch_fileresolver.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include +#include #include -- cgit v1.2.1