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 |
628 | 628 | po/Makefile.in |
629 | 629 | ]) |
630 | 630 | |
631 | | if test x$enable_tests != xno; then |
632 | | AC_CONFIG_FILES([ |
| 631 | AC_CONFIG_FILES([ |
633 | 632 | tests/Makefile |
634 | 633 | tests/lib/Makefile |
635 | 634 | tests/lib/mcconfig/Makefile |
… |
… |
tests/src/vfs/Makefile |
645 | 644 | tests/src/vfs/extfs/Makefile |
646 | 645 | tests/src/vfs/extfs/helpers-list/Makefile |
647 | 646 | ]) |
648 | | fi |
649 | 647 | |
650 | 648 | AC_OUTPUT |
651 | 649 | |
… |
… |
Configuration: |
657 | 655 | Compiler: ${CC} |
658 | 656 | Compiler flags: ${CFLAGS} |
659 | 657 | Assertions: ${enable_assert} |
| 658 | Unit tests: ${tests_msg} |
660 | 659 | File system: ${vfs_type} |
661 | 660 | ${vfs_flags} |
662 | 661 | Screen library: ${screen_msg} |
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],[ |
11 | 11 | |
12 | 12 | AC_ARG_ENABLE( |
13 | 13 | [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@:>@]) |
15 | 15 | ) |
16 | 16 | |
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 |
18 | 23 | PKG_CHECK_MODULES( |
19 | 24 | CHECK, |
20 | 25 | [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 | ]) |
23 | 40 | AC_SUBST(CHECK_CFLAGS) |
24 | 41 | AC_SUBST(CHECK_LIBS) |
25 | 42 | fi |
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fc16371..de3ff6c 100644
a
|
b
|
|
1 | 1 | SUBDIRS = lib src |
2 | 2 | |
3 | | EXTRA_DIST = mctest.h |
| 3 | EXTRA_DIST = mctest.h README |
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..f606d1d
-
|
+
|
|
| 1 | Overview |
| 2 | -------- |
| 3 | |
| 4 | This tree contains unit tests. |
| 5 | |
| 6 | To compile and run the tests, do 'make check' (either in the top folder, |
| 7 | or just in the folder containing the tests you're interested in). |
| 8 | |
| 9 | IMPORTANT: To compile the tests, you need to have the "Check" unit |
| 10 | testing 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 |
| 12 | message, you won't be able to compile the tests.[3] |
| 13 | |
| 14 | Tips 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 |