Skip to content

Commit

Permalink
Use pch for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Waqar144 committed Nov 1, 2024
1 parent 6075e1e commit 0e82b20
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/backtracebrowser/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ target_sources(btbrowser_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../btparser.cpp
)

if(BUILD_PCH)
target_precompile_headers(btbrowser_test REUSE_FROM katepch_tests)
endif()

add_test(NAME plugin-btbrowser_test COMMAND btbrowser_test ${OFFSCREEN_QPA})
ecm_mark_as_test(btbrowser_test)
4 changes: 4 additions & 0 deletions addons/externaltools/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ add_executable(externaltools_test
add_test(NAME plugin-externaltools_test COMMAND externaltools_test ${OFFSCREEN_QPA})
target_link_libraries(externaltools_test PRIVATE kateprivate Qt::Test KF6::I18n KF6::ConfigCore KF6::CoreAddons KF6::TextEditor)
ecm_mark_as_test(externaltools_test)

if(BUILD_PCH)
target_precompile_headers(externaltools_test REUSE_FROM katepch_tests)
endif()
4 changes: 4 additions & 0 deletions addons/filetree/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ target_sources(
document_dummy.cpp
)

if(BUILD_PCH)
target_precompile_headers(filetree_model_test REUSE_FROM katepch_tests)
endif()

add_test(NAME kateapp-filetree_model_test COMMAND filetree_model_test ${OFFSCREEN_QPA})
ecm_mark_as_test(filetree_model_test)
4 changes: 4 additions & 0 deletions addons/format/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ target_sources(
test_formatapply.cpp
)

if(BUILD_PCH)
target_precompile_headers(test_formatapply REUSE_FROM katepch_tests)
endif()

add_test(NAME kateapp-test_formatapply COMMAND test_formatapply ${OFFSCREEN_QPA})
ecm_mark_as_test(test_formatapply)
6 changes: 6 additions & 0 deletions addons/gdbplugin/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ target_link_libraries(
)
add_test(NAME plugin-gdb_test_gdbvariableparse COMMAND gdbplugin_test_gdbvariableparser ${OFFSCREEN_QPA})
ecm_mark_as_test(gdbplugin_test_gdbvariableparser)

if(BUILD_PCH)
target_precompile_headers(gdbplugin_test_gdbmi REUSE_FROM katepch_tests)
target_precompile_headers(gdbplugin_test_gdbbackend REUSE_FROM katepch_tests)
target_precompile_headers(gdbplugin_test_gdbvariableparser REUSE_FROM katepch_tests)
endif()
4 changes: 4 additions & 0 deletions addons/latexunicodecompletion/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ target_include_directories(latexcompletion_test PRIVATE ${CMAKE_CURRENT_SOURCE_D
add_test(NAME plugin-latexunicodecompletion_test COMMAND latexcompletion_test)
target_link_libraries(latexcompletion_test Qt::Core Qt::Test)
ecm_mark_as_test(latexcompletion_test)

if(BUILD_PCH)
target_precompile_headers(latexcompletion_test REUSE_FROM katepch_tests)
endif()
4 changes: 4 additions & 0 deletions addons/lspclient/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ target_sources(
../semantic_tokens_legend.cpp
${DEBUG_SOURCES}
)

if(BUILD_PCH)
target_precompile_headers(lsptestapp REUSE_FROM katepch_tests)
endif()
4 changes: 4 additions & 0 deletions addons/openlink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ if (BUILD_TESTING)
add_test(NAME linkmatchtest COMMAND linkmatchtest ${OFFSCREEN_QPA})
target_link_libraries(linkmatchtest PRIVATE kateprivate Qt::Test Qt::Core)
ecm_mark_as_test(linkmatchtest)

if(BUILD_PCH)
target_precompile_headers(linkmatchtest REUSE_FROM katepch_tests)
endif()
endif()
4 changes: 4 additions & 0 deletions addons/project/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/../kateprojectcodeanalysistool.cpp
)

if(BUILD_PCH)
target_precompile_headers(projectplugin_test REUSE_FROM katepch_tests)
endif()

add_test(NAME plugin-project_test COMMAND projectplugin_test ${OFFSCREEN_QPA})
ecm_mark_as_test(projectplugin_test)
4 changes: 4 additions & 0 deletions addons/tabswitcher/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ target_sources(
../tabswitcherfilesmodel.cpp
)

if(BUILD_PCH)
target_precompile_headers(tabswitcher_test REUSE_FROM katepch_tests)
endif()

add_test(NAME plugin-tabswitcher_test COMMAND tabswitcher_test ${OFFSCREEN_QPA})
ecm_mark_as_test(tabswitcher_test)
4 changes: 4 additions & 0 deletions addons/tabswitcher/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ target_sources(
tstestapp.cpp
../tabswitcherfilesmodel.cpp
)

if(BUILD_PCH)
target_precompile_headers(tstestapp REUSE_FROM katepch_tests)
endif()
4 changes: 4 additions & 0 deletions apps/lib/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ macro(kate_executable_tests)
kateprivate Qt::Test)
add_test(NAME kateapp-${_testname} COMMAND ${_testname} ${OFFSCREEN_QPA})
ecm_mark_as_test(${_testname})

if(BUILD_PCH)
target_precompile_headers(${_testname} REUSE_FROM katepch_tests)
endif()
endforeach()
endmacro()

Expand Down
29 changes: 29 additions & 0 deletions pch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,32 @@ add_library(katepch STATIC ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp ${CMAKE_CUR
target_precompile_headers(katepch PRIVATE pch.h)
set_target_properties(katepch PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(katepch PRIVATE Qt::Core Qt::Gui Qt::Widgets)

find_package(Qt6Test ${QT_MIN_VERSION} QUIET REQUIRED)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/kate_test_pch.h
"#pragma once
#include <QObject>
#include <QString>
#include <QtGlobal>
#include <type_traits>
#include <QMetaObject>
#include <QBitArray>
#include <QByteArray>
#include <QCborArray>
#include <QtCborCommon>
#include <QCborMap>
#include <QCborValue>
#include <QStringList>
#include <QDateTime>
#include <algorithm>
#include <QDebug>
#include <thread>
#include <semaphore>
#include <future>
#include <atomic>
#include <QThread>
")
add_library(katepch_tests STATIC ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp)
target_precompile_headers(katepch_tests PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/kate_test_pch.h)
target_link_libraries(katepch_tests PRIVATE Qt::Core)

0 comments on commit 0e82b20

Please sign in to comment.