Ticket #3708: fix usability problems with --enable-tests

Signed-off-by: Mooffie <mooffie@gmail.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Mooffie 2016-10-31 18:03:41 +02:00 committed by Yury V. Zaytsev
parent f40caa3e71
commit 4a559344fb
4 changed files with 49 additions and 8 deletions

View File

@ -628,8 +628,7 @@ intl/Makefile
po/Makefile.in po/Makefile.in
]) ])
if test x$enable_tests != xno; then AC_CONFIG_FILES([
AC_CONFIG_FILES([
tests/Makefile tests/Makefile
tests/lib/Makefile tests/lib/Makefile
tests/lib/mcconfig/Makefile tests/lib/mcconfig/Makefile
@ -645,7 +644,6 @@ tests/src/vfs/Makefile
tests/src/vfs/extfs/Makefile tests/src/vfs/extfs/Makefile
tests/src/vfs/extfs/helpers-list/Makefile tests/src/vfs/extfs/helpers-list/Makefile
]) ])
fi
AC_OUTPUT AC_OUTPUT
@ -657,6 +655,7 @@ Configuration:
Compiler: ${CC} Compiler: ${CC}
Compiler flags: ${CFLAGS} Compiler flags: ${CFLAGS}
Assertions: ${enable_assert} Assertions: ${enable_assert}
Unit tests: ${tests_msg}
File system: ${vfs_type} File system: ${vfs_type}
${vfs_flags} ${vfs_flags}
Screen library: ${screen_msg} Screen library: ${screen_msg}

View File

@ -11,15 +11,32 @@ AC_DEFUN([mc_UNIT_TESTS],[
AC_ARG_ENABLE( AC_ARG_ENABLE(
[tests], [tests],
AS_HELP_STRING([--enable-tests], [Enable unit tests (see http://check.sourceforge.net/)]) AS_HELP_STRING([--enable-tests], [Enable unit tests (see http://libcheck.github.io/check/) @<:@auto@:>@])
) )
if test x$enable_tests != xno; then dnl 'tests_msg' holds the human-readable message to show in configure's summary text.
if test x$enable_tests == xno; then
dnl The user explicitly specified '--disable-tests'.
tests_msg="no"
else
PKG_CHECK_MODULES( PKG_CHECK_MODULES(
CHECK, CHECK,
[check >= 0.9.8], [check >= 0.9.8],
[have_check=yes], [
[AC_MSG_WARN(['Check' utility not found. Check your environment])]) have_check=yes
tests_msg="yes"
],
[
AC_MSG_WARN(['Check' testing framework not found. Check your environment])
tests_msg="no ('Check' testing framework not found)"
dnl The following behavior, of "exit if feature requested but not found", is just a
dnl preference and can be safely removed.
if test x$enable_tests == xyes; then
AC_MSG_ERROR([You explicitly specified '--enable-tests', but this requirement cannot be met.])
fi
])
AC_SUBST(CHECK_CFLAGS) AC_SUBST(CHECK_CFLAGS)
AC_SUBST(CHECK_LIBS) AC_SUBST(CHECK_LIBS)
fi fi

View File

@ -1,3 +1,3 @@
SUBDIRS = lib src SUBDIRS = lib src
EXTRA_DIST = mctest.h EXTRA_DIST = mctest.h README

25
tests/README Normal file
View File

@ -0,0 +1,25 @@
Overview
--------
This tree contains unit tests.
To compile and run the tests, do 'make check' (either in the top folder,
or just in the folder containing the tests you're interested in).
IMPORTANT: To compile the tests, you need to have the "Check" unit
testing framework[1] installed.[2] If you have it installed, you will see
"Unit tests: yes" in configure's summary message; if you don't see this
message, you won't be able to compile the tests.[3]
Tips and tricks
---------------
* To be able to step with the debugger into test code, see [4]. E.g., do:
$ export CK_FORK=no
[1]: http://libcheck.github.io/check/
[2]: Your package manager likely has it.
[3]: Actually, some tests (like src/vfs/extfs/helpers-list) don't use
this framework and will compile just fine. But that's the exception.
[4]: http://stackoverflow.com/questions/1649814/debugging-unit-test-in-c-using-check