1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

CMake: Add test_scripts.sh to the tests.

In contrast to Automake, skipping of this test when decoders
are disabled is handled at CMake side instead of test_scripts.sh
because CMake-build doesn't create config.h.
This commit is contained in:
Lasse Collin 2024-02-17 15:35:35 +02:00
parent 4808f238a7
commit 74e8bc7417
2 changed files with 22 additions and 5 deletions

View file

@ -1803,4 +1803,18 @@ if(BUILD_TESTING)
SKIP_RETURN_CODE 77 SKIP_RETURN_CODE 77
) )
endforeach() endforeach()
if(UNIX AND HAVE_DECODERS)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_scripts")
add_test(NAME test_scripts.sh
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_scripts.sh" ".."
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_scripts"
)
set_tests_properties(test_scripts.sh PROPERTIES
ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}/tests"
SKIP_RETURN_CODE 77
)
endif()
endif() endif()

View file

@ -8,9 +8,11 @@
############################################################################### ###############################################################################
# If scripts weren't built, this test is skipped. # If scripts weren't built, this test is skipped.
XZ=../src/xz/xz # When this is run from CMake, $1 is a relative path
XZDIFF=../src/scripts/xzdiff # to the directory with the executables and the scripts.
XZGREP=../src/scripts/xzgrep XZ=${1:-../src/xz}/xz
XZDIFF=${1:-../src/scripts}/xzdiff
XZGREP=${1:-../src/scripts}/xzgrep
for i in XZ XZDIFF XZGREP; do for i in XZ XZDIFF XZGREP; do
eval test -x "\$$i" && continue eval test -x "\$$i" && continue
@ -21,14 +23,15 @@ done
# Installing the scripts in this case is a bit silly but they # Installing the scripts in this case is a bit silly but they
# could still be used with other decompression tools so configure # could still be used with other decompression tools so configure
# doesn't automatically disable scripts if decoders are disabled. # doesn't automatically disable scripts if decoders are disabled.
if grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then if test ! -f ../config.h \
|| grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
: :
else else
echo "Decompression support is disabled, skipping this test." echo "Decompression support is disabled, skipping this test."
exit 77 exit 77
fi fi
PATH=`pwd`/../src/xz:$PATH PATH=`pwd`/${1:-../src/xz}:$PATH
export PATH export PATH
test -z "$srcdir" && srcdir=. test -z "$srcdir" && srcdir=.