7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:09:17 +00:00

Fix ctest for windows with env shim that is disabled for non windows, for now.

Also stuff a dummy fontconfig file to silence the dumb error on stdout, which interferes with testing
This commit is contained in:
Marek Roszko 2025-01-04 22:08:06 -05:00
parent cb948302e2
commit 02b3d03c23
10 changed files with 161 additions and 10 deletions

View File

@ -550,10 +550,14 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit, bool aIsUnitTest )
SetDefaultLanguage( tmp );
#ifdef _MSC_VER
// We need to set this because the internal fontconfig logic
// seems to search relative to the dll rather the other logic it
// has to look for the /etc folder above the dll
wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() );
if( !wxGetEnv( "FONTCONFIG_PATH", NULL ) )
{
// We need to set this because the internal fontconfig logic
// seems to search relative to the dll rather the other logic it
// has to look for the /etc folder above the dll
// Also don't set it because we need it in QA cli tests to be set by ctest
wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() );
}
#endif
m_settings_manager = std::make_unique<SETTINGS_MANAGER>( aHeadless );

View File

@ -21,6 +21,25 @@
include( KiCadQABuildUtils )
macro(setup_qa_env target_name)
if( MSVC )
# Once we move the cmake minimum to 3.22, we can use this for all platforms and not just MSVC
# the old method only worked on MSVC due to a bug in cmake which was later fixed after ENVIRONMENT_MODIFICATION was added
set( PATH_MODIFICATION
"PATH=path_list_prepend:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/kicad/"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/common/"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/api/"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/common/gal/"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/pcbnew/"
"PATH=path_list_prepend:${CMAKE_BINARY_DIR}/eeschema/" )
set_tests_properties( ${target_name}
PROPERTIES
ENVIRONMENT_MODIFICATION "${PATH_MODIFICATION}"
)
endif()
endmacro()
# Shared QA helper libraries
add_subdirectory( qa_utils )
add_subdirectory( pcbnew_utils )

View File

@ -0,0 +1,103 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<description>Default configuration file</description>
<!--
DO NOT EDIT THIS FILE.
IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
LOCAL CHANGES BELONG IN 'local.conf'.
The intent of this standard configuration file is to be adequate for
most environments. If you have a reasonably normal environment and
have found problems with this configuration, they are probably
things that others will also want fixed. Please submit any problems
to the fontconfig issue tracking system located at fontconfig.org
Note that the normal 'make install' procedure for fontconfig is to
replace any existing fonts.conf file with the new version. Place
any local customizations in local.conf which this file references.
Keith Packard
-->
<!-- Font directory list -->
<dir>WINDOWSFONTDIR</dir>
<dir>WINDOWSUSERFONTDIR</dir>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept alternate 'system ui' spelling, replacing it with 'system-ui'
-->
<match target="pattern">
<test qual="any" name="family">
<string>system ui</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>system-ui</string>
</edit>
</match>
<!--
Load local system customization file
-->
<include ignore_missing="yes">conf.d</include>
<!-- Font cache directory list -->
<cachedir>LOCAL_APPDATA_FONTCONFIG_CACHE</cachedir>
<cachedir prefix="xdg">fontconfig</cachedir>
<!-- the following element will be removed in the future -->
<cachedir>~/.fontconfig</cachedir>
<config>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig>

View File

@ -57,15 +57,19 @@ ${NEW_PATHS};" )
get_filename_component( CAIRO_LIB_BASE "${CAIRO_LIBRARY}" DIRECTORY )
set( EXTRA_PYTEST_ENVIRONMENT "DYLD_FALLBACK_LIBRARY_PATH=${CAIRO_LIB_BASE}" )
elseif ( MSVC )
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set( NEW_PATHS
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin;\
${NEW_PATHS};" )
${NEW_PATHS};" )
else()
set( NEW_PATHS
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin;\
${NEW_PATHS};" )
${NEW_PATHS};" )
endif()
set( EXTRA_PYTEST_ENVIRONMENT "FONTCONFIG_PATH=${CMAKE_SOURCE_DIR}/qa/resources/windows/fonts/" )
endif()
set( QA_PATH_REPLACEMENT "PATH=${NEW_PATHS};$ENV{PATH}" )
@ -94,7 +98,16 @@ add_test(NAME qa_cli
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties( qa_cli
PROPERTIES
ENVIRONMENT "${QA_PATH_REPLACEMENT};KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}"
)
if( NOT MSVC )
set_tests_properties( qa_cli
PROPERTIES
ENVIRONMENT "${QA_PATH_REPLACEMENT};KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}"
)
else()
set_tests_properties( qa_cli
PROPERTIES
ENVIRONMENT "KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}"
)
setup_qa_env( qa_cli )
endif()

View File

@ -57,3 +57,5 @@ target_include_directories( qa_api PRIVATE
)
kicad_add_boost_test( qa_api qa_api )
setup_qa_env( qa_api )

View File

@ -116,3 +116,5 @@ if( KICAD_TEST_DATABASE_LIBRARIES )
endif()
kicad_add_boost_test( qa_common qa_common )
setup_qa_env( qa_common )

View File

@ -123,3 +123,5 @@ target_compile_definitions( qa_eeschema
)
kicad_add_boost_test( qa_eeschema qa_eeschema )
setup_qa_env( qa_eeschema )

View File

@ -75,3 +75,5 @@ target_link_libraries( qa_gerbview
)
kicad_add_boost_test( qa_gerbview qa_gerbview )
setup_qa_env( qa_gerbview )

View File

@ -89,3 +89,5 @@ target_include_directories( qa_kimath PRIVATE
)
kicad_add_boost_test( qa_kimath qa_kimath )
setup_qa_env( qa_kimath )

View File

@ -150,3 +150,5 @@ if( WIN32 )
endif()
kicad_add_boost_test( qa_pcbnew qa_pcbnew )
setup_qa_env( qa_pcbnew )