Ticket #3708: 3708-Fix-usability-problems-in-enable-tests--v3.patch

File 3708-Fix-usability-problems-in-enable-tests--v3.patch, 4.1 KB (added by mooffie, 2 years ago)
  • configure.ac

    From 572fdceec67fa68e2173c11851ea4436202315e1 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Mon, 31 Oct 2016 18:03:41 +0200
    Subject: [PATCH 1/2] Fix usability problems with --enable-tests.
    
    ---
     configure.ac           |  5 ++---
     m4.include/mc-tests.m4 | 25 +++++++++++++++++++++----
     tests/Makefile.am      |  2 +-
     tests/README           | 25 +++++++++++++++++++++++++
     4 files changed, 49 insertions(+), 8 deletions(-)
     create mode 100644 tests/README
    
    diff --git a/configure.ac b/configure.ac
    index 38776bf..87576f0 100644
    a b intl/Makefile 
    628628po/Makefile.in 
    629629]) 
    630630 
    631 if test x$enable_tests != xno; then 
    632     AC_CONFIG_FILES([ 
     631AC_CONFIG_FILES([ 
    633632tests/Makefile 
    634633tests/lib/Makefile 
    635634tests/lib/mcconfig/Makefile 
    tests/src/vfs/Makefile 
    645644tests/src/vfs/extfs/Makefile 
    646645tests/src/vfs/extfs/helpers-list/Makefile 
    647646]) 
    648 fi 
    649647 
    650648AC_OUTPUT 
    651649 
    Configuration: 
    657655  Compiler:                   ${CC} 
    658656  Compiler flags:             ${CFLAGS} 
    659657  Assertions:                 ${enable_assert} 
     658  Unit tests:                 ${tests_msg} 
    660659  File system:                ${vfs_type} 
    661660                              ${vfs_flags} 
    662661  Screen library:             ${screen_msg} 
  • m4.include/mc-tests.m4

    diff --git a/m4.include/mc-tests.m4 b/m4.include/mc-tests.m4
    index c991fbb..742ecb0 100644
    a b AC_DEFUN([mc_UNIT_TESTS],[ 
    1111 
    1212    AC_ARG_ENABLE( 
    1313        [tests], 
    14         AS_HELP_STRING([--enable-tests], [Enable unit tests (see http://check.sourceforge.net/)]) 
     14        AS_HELP_STRING([--enable-tests], [Enable unit tests (see http://libcheck.github.io/check/) @<:@auto@:>@]) 
    1515    ) 
    1616 
    17     if test x$enable_tests != xno; then 
     17    dnl 'tests_msg' holds the human-readable message to show in configure's summary text. 
     18 
     19    if test x$enable_tests == xno; then 
     20        dnl The user explicitly specified '--disable-tests'. 
     21        tests_msg="no" 
     22    else 
    1823        PKG_CHECK_MODULES( 
    1924            CHECK, 
    2025            [check >= 0.9.8], 
    21             [have_check=yes], 
    22             [AC_MSG_WARN(['Check' utility not found. Check your environment])]) 
     26            [ 
     27                have_check=yes 
     28                tests_msg="yes" 
     29            ], 
     30            [ 
     31                AC_MSG_WARN(['Check' testing framework not found. Check your environment]) 
     32                tests_msg="no ('Check' testing framework not found)" 
     33 
     34                dnl The following behavior, of "exit if feature requested but not found", is just a 
     35                dnl preference and can be safely removed. 
     36                if test x$enable_tests == xyes; then 
     37                    AC_MSG_ERROR([You explicitly specified '--enable-tests', but this requirement cannot be met.]) 
     38                fi 
     39            ]) 
    2340        AC_SUBST(CHECK_CFLAGS) 
    2441        AC_SUBST(CHECK_LIBS) 
    2542    fi 
  • tests/Makefile.am

    diff --git a/tests/Makefile.am b/tests/Makefile.am
    index fc16371..de3ff6c 100644
    a b  
    11SUBDIRS = lib src 
    22 
    3 EXTRA_DIST = mctest.h 
     3EXTRA_DIST = mctest.h README 
  • new file tests/README

    diff --git a/tests/README b/tests/README
    new file mode 100644
    index 0000000..f606d1d
    - +  
     1Overview 
     2-------- 
     3 
     4This tree contains unit tests. 
     5 
     6To compile and run the tests, do 'make check' (either in the top folder, 
     7or just in the folder containing the tests you're interested in). 
     8 
     9IMPORTANT: To compile the tests, you need to have the "Check" unit 
     10testing framework[1] installed.[2] If you have it installed, you will see 
     11"Unit tests: yes" in configure's summary message; if you don't see this 
     12message, you won't be able to compile the tests.[3] 
     13 
     14Tips and tricks 
     15--------------- 
     16 
     17* To be able to step with the debugger into test code, see [4]. E.g., do: 
     18 
     19    $ export CK_FORK=no 
     20 
     21[1]: http://libcheck.github.io/check/ 
     22[2]: Your package manager likely has it. 
     23[3]: Actually, some tests (like src/vfs/extfs/helpers-list) don't use 
     24     this framework and will compile just fine. But that's the exception. 
     25[4]: http://stackoverflow.com/questions/1649814/debugging-unit-test-in-c-using-check