aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-11 11:14:52 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-11 11:14:52 +0300
commit6a7581f2e60a600a4915e4f55b74a15c80701978 (patch)
tree373f11b6a83a1e509320dd9b303334da7b427bd6
parent6ccb9ad200f6fa0b59a3d17e7e069badb2d39e50 (diff)
downloadwordsplit-6a7581f2e60a600a4915e4f55b74a15c80701978.tar.gz
wordsplit-6a7581f2e60a600a4915e4f55b74a15c80701978.tar.bz2
Change the testsuite files to be easily incorporated into an existing testsuite
* README: Rewrite the testuite section. * wordsplit.at: Remove AT_INIT * wsp.c: Include wordsplit-version.h before wordsplit.h
-rw-r--r--README135
-rw-r--r--wordsplit.at1
-rw-r--r--wsp.c2
3 files changed, 56 insertions, 82 deletions
diff --git a/README b/README
index 59f3436..96ffbec 100644
--- a/README
+++ b/README
@@ -15,21 +15,21 @@ The following code fragment shows the basic usage:
/* This variable controls parsing */
wordsplit_t ws;
int rc;
-
+
/* Provide variable definitions */
ws.ws_env = (const char **) environ;
/* Provide a function for expanding commands */
ws.ws_command = runcom;
/* Split input_string into words */
rc = wordsplit(input_string, &ws,
- WRDSF_QUOTE /* Handle both single and
- double quoted strings as words. */
+ WRDSF_QUOTE /* Handle both single and
+ double quoted strings as words. */
| WRDSF_SQUEEZE_DELIMS /* Compress adjacent delimiters */
| WRDSF_PATHEXPAND /* Expand pathnames */
- | WRDSF_SHOWERR); /* Show errors */
+ | WRDSF_SHOWERR); /* Show errors */
if (rc == 0) {
/* Success. The resulting words are returned in the NULL-terminated
- array ws.ws_wordv. Number of words is in ws.ws_wordc */
+ array ws.ws_wordv. Number of words is in ws.ws_wordc */
}
/* Reclaim the allocated memory */
wordsplit_free(&ws);
@@ -80,19 +80,19 @@ Add the subdir-objects option to the invocation of AM_INIT_AUTOMAKE macro in
your configure.ac:
AM_INIT_AUTOMAKE([subdir-objects])
-
+
In your Makefile.am, add both wordsplit/wordsplit.c and wordsplit/wordsplit.h
to the sources and -Iwordsplit to the cpp flags. For example:
program_SOURCES = main.c \
- wordsplit/wordsplit.c \
- wordsplit/wordsplit.h
+ wordsplit/wordsplit.c \
+ wordsplit/wordsplit.h
AM_CPPFLAGS = -I$(srcdir)/wordsplit
You can also put wordsplit.h in the noinst_HEADERS variable, if you like:
program_SOURCES = main.c \
- wordsplit/wordsplit.c
+ wordsplit/wordsplit.c
noinst_HEADERS = wordsplit/wordsplit.h
AM_CPPFLAGS = -I$(srcdir)/wordsplit
@@ -101,7 +101,7 @@ wordsplit API, install wordsplit.h to $(pkgincludedir), e.g.
lib_LTLIBRARIES = libmy.la
libmy_la_SOURCES = main.c \
- wordsplit/wordsplit.c
+ wordsplit/wordsplit.c
AM_CPPFLAGS = -I$(srcdir)/wordsplit
pkginclude_HEADERS = wordsplit/wordsplit.h
@@ -145,93 +145,69 @@ It is also possible to use LDADD as shown in the example below:
The package contains two files for building the testsuite: wsp.c,
which is used to build the auxiliary binary wsp, and wordsplit.at,
-which is translated by GNU autotest into a testsuite shell script.
+which can be included to a GNU autotest-based testsuite source.
The discussion below is for those who wish to include wordsplit
-testsuite into their project. It assumes the following layout of the
-hosting project:
-
- lib/
- Directory holding the library that incorporates wordsplit.o.
- This discussion assumes the library name is libmy.a
- lib/wordsplit
- Wordsplit sources.
-
-The testsuite will be built in lib.
+testsuite into their project. It assumes that the hosting project
+already has an autotest-based testsuite.
** Additional files
-Three additional files are necessary for the testsuite: atlocal.in,
-wordsplit-version.h, and package.m4.
-
-The file atlocal.in is a simple shell script that sets the PATH
-environment variable for the testsuite. It contains just one line:
-
- PATH=$srcdir/wordsplit:$PATH
-
-The file wordsplit-version.h provides the version definition for the
-test program wsp.c. Use the following script to create it:
+To build the auxiliary tool wsp, you will need an additional file,
+wordsplit-version.h. Normally, it should contain only a definition
+of the macro or variable WORDSPLIT_VERSION. The following shell
+fragment can be used to create it:
version=$(cd wordsplit; git describe)
cat > wordsplit-version.h <<EOF
#define WORDSPLIT_VERSION "$version"
EOF
-The file package.m4 contains package description which allows
-testsuite to generate an accurate report. To create it, use:
+This file should be listed in the EXTRA_DIST variable to make sure
+it is distributed with the tarball.
- cat > package.m4 <<EOF
- m4_define([AT_PACKAGE_NAME], [wordsplit])
- m4_define([AT_PACKAGE_TARNAME], [wordsplit])
- m4_define([AT_PACKAGE_VERSION], [$version])
- m4_define([AT_PACKAGE_STRING], [AT_PACKAGE_NAME AT_PACKAGE_VERSION])
- m4_define([AT_PACKAGE_BUGREPORT], [gray@gnu.org])
- EOF
-
-Here, $version is the same variable you used for wordsplit-version.h.
-
-After creating the three files, list them in the EXTRA_DIST variable in
-lib/Makefile.am to make sure they will be distributed with the tarball.
-
-** configure.ac
+** testsuite.at
-Add the following lines to your configure.ac:
+Include the file wordsplit.at to your testsuite.at:
- AM_MISSING_PROG([AUTOM4TE], [autom4te])
+ m4_include(wordsplit.at)
- AC_CONFIG_TESTDIR([lib])
- AC_CONFIG_FILES([lib/Makefile lib/atlocal])
+** Makefile.am
-** lib/Makefile.am
+In the Makefile.am responsible for creating the testsuite, make sure
+that the path to the wordsplit module is passed to the autotest
+invocation, so that the above m4_include statement will work. The
+usual make goal to build the testsuite looks as follows:
-The Makefile.am in lib must be modified to build the auxiliary program
-wsp and create the testsuite script. This is done by the following
-fragment:
+ $(TESTSUITE): package.m4 $(TESTSUITE_AT)
+ $(AM_V_GEN)$(AUTOTEST) \
+ -I $(srcdir)\
+ -I $(top_srcdir)/wordsplit\
+ testsuite.at -o $@.tmp
+ $(AM_V_at)mv $@.tmp $@
- EXTRA_DIST = testsuite wordsplit/wordsplit.at package.m4
- DISTCLEANFILES = atconfig
- MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
+Then, add the following fragment to build the auxiliary files:
- TESTSUITE = $(srcdir)/testsuite
- M4=m4
- AUTOTEST = $(AUTOM4TE) --language=autotest
- $(TESTSUITE): src/wordsplit.at
- $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) wordsplit/wordsplit.at \
- -o $(TESTSUITE).tmp
- $(AM_V_at)mv $(TESTSUITE).tmp $(TESTSUITE)
+ # ###########################
+ # Wordsplit testsuite
+ # ###########################
+ EXTRA_DIST += wordsplit-version.h
+ $(srcdir)/wordsplit-version.h: $(top_srcdir)/configure.ac
+ $(AM_V_GEN){\
+ if test -e $(top_srcdir)/libmailutils/wordsplit/.git; then \
+ wsversion=$$(cd $(top_srcdir)/libmailutils/wordsplit; git describe); \
+ else \
+ wsversion="unknown"; \
+ fi;\
+ echo "#define WORDSPLIT_VERSION \"$wsversion\"";\
+ echo '#include <mailutils/wordsplit.h>'; } > \
+ > $(srcdir)/wordsplit-version.h
- noinst_PROGRAMS = wsp
- wsp_SOURCES = wordsplit/wsp.c wordsplit-version.h
- wsp_LDADD = ./libmy.a
-
- atconfig: $(top_builddir)/config.status
- cd $(top_builddir) && ./config.status $@
-
- clean-local:
- @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
-
- check-local: atconfig atlocal $(TESTSUITE)
- @$(SHELL) $(TESTSUITE)
+ noinst_PROGRAMS += wsp
+ wsp_SOURCES =
+ nodist_wsp_SOURCES = wsp.c
+ wsp.o: $(srcdir)/wordsplit-version.h
+ VPATH += $(top_srcdir)/libmailutils/wordsplit
* History
@@ -282,7 +258,7 @@ projects.
Git: <http://git.gnu.org.ua/cgit/fileserv.git>
[8] vmod-dbrw - Database-driven rewrite rules for Varnish Cache
Home: <http://puszcza.gnu.org.ua/software/vmod-dbrw>
- Git: <http://git.gnu.org.ua/cgit/vmod-dbrw.git>
+ Git: <http://git.gnu.org.ua/cgit/vmod-dbrw.git>
* Bug reporting
@@ -311,7 +287,6 @@ changed them.
Local Variables:
mode: outline
-paragraph-separate: "[ ]*$"
+paragraph-separate: "[ ]*$"
version-control: never
End:
-
diff --git a/wordsplit.at b/wordsplit.at
index 52a4a75..d7d8bc9 100644
--- a/wordsplit.at
+++ b/wordsplit.at
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with wordsplit. If not, see <http://www.gnu.org/licenses/>.
-AT_INIT
AT_TESTED(wsp)
m4_pushdef([wspnum],[0])
diff --git a/wsp.c b/wsp.c
index 8dd7dc9..cea7980 100644
--- a/wsp.c
+++ b/wsp.c
@@ -22,8 +22,8 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
-#include "wordsplit.h"
#include "wordsplit-version.h"
+#include "wordsplit.h"
extern char **environ;

Return to:

Send suggestions and report system problems to the System administrator.