Make the scheme tests fail immediately if they load an external gnucash file

This would be a mistake in the build, but can happen if there
is already a gnucash installed in the standard guile load path.
This commit is contained in:
Richard Cohen
2023-02-23 21:53:03 +00:00
parent 675d894128
commit 7cae61d97a

View File

@@ -109,7 +109,17 @@ endfunction()
function(gnc_add_scheme_test _TARGET _SOURCE_FILE)
add_test(${_TARGET} ${CMAKE_COMMAND} -E env
${GUILE_EXECUTABLE} --debug -c "(load-from-path \"${_TARGET}\")(exit (run-test))"
${GUILE_EXECUTABLE} --debug -c "
(set! %load-hook
(lambda (filename)
(when (and filename
(string-contains filename \"${GUILE_REL_SITEDIR}\")
(not (string-prefix? \"${CMAKE_BINARY_DIR}\" filename)))
(format #t \"%load-path = ~s~%\" %load-path)
(format #t \"%load-compiled-path = ~s~%\" %load-compiled-path)
(error \"Loading guile/site file from outside build tree!\" filename))))
(load-from-path \"${_TARGET}\")
(exit (run-test))"
)
get_guile_env()
set_tests_properties(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}")