From 6a7581f2e60a600a4915e4f55b74a15c80701978 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 11 Jul 2019 11:14:52 +0300 Subject: 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 --- README | 135 ++++++++++++++++++++++++----------------------------------- wordsplit.at | 1 - wsp.c | 2 +- 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 < package.m4 <'; } > \ + > $(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: [8] vmod-dbrw - Database-driven rewrite rules for Varnish Cache Home: - Git: + 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 . -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 #include #include -#include "wordsplit.h" #include "wordsplit-version.h" +#include "wordsplit.h" extern char **environ; -- cgit v1.2.1