From a156fb19de017c6d101b0e4cebbe3ea6819e7d40 Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Tue, 4 Dec 2012 19:50:10 -0600 Subject: [PATCH] get testing working in autoconf --- Makefile.am | 4 +--- README | 5 +++++ jq_test.c | 13 ++++++++++++- setup.sh | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2b0abeb7..06d9c55a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ # setup is only used by distribution developers, not package developers. # Still, as a matter of allowing patching, its not a bad idea to distribute # the developer setup script in the tarball. -EXTRA_DIST = setup.sh config.h.in ChangeLog VERSION lexer.l lexer.h gen_utf8_tables.py jq.spec +EXTRA_DIST = setup.sh config.h.in ChangeLog VERSION lexer.l lexer.h gen_utf8_tables.py jq.spec testdata # README.md is expected in Github projects, good stuff in it, so we'll # distribute it and install it with the package in the doc directory. @@ -27,13 +27,11 @@ bin_PROGRAMS = jq jq_test BUILT_SOURCES = jv_utf8_tables.gen.h lexer.h lexer.c jq_SOURCES = $(JQ_SRC) main.c jq_CPPFLAGS = $(DEVCFLAGS) -O -DJQ_DEBUG=0 -jq_CFLAGS = $(DEVCFLAGS) -O -DJQ_DEBUG=0 TESTS = jq_test jq_test_SOURCES = $(JQ_SRC) jq_test.c jq_test_CPPFLAGS = $(DEVCFLAGS) -DJQ_DEBUG=1 -jq_test_CFLAGS = $(DEVCFLAGS) -DJQ_DEBUG=1 LOG_COMPILER = valgrind AM_LOG_FLAGS = --error-exitcode=1 -q --leak-check=full diff --git a/README b/README index c6933dae..d84e95ee 100644 --- a/README +++ b/README @@ -3,3 +3,8 @@ README file is not used, README.md is the file to READ! When you checkout the file, run "setup.sh" which gets autoconf initialized. Then follow the instructions in INSTALL. Real standard stuff... + + + $ ./setup.sh # initializes Autoconf and builds your release + $ ./setup.sh clean # cleans all the temp files out of your tree + $ ./setup.sh superclean # deletes your release files so you can try again diff --git a/jq_test.c b/jq_test.c index b4674c81..dd41a2f9 100644 --- a/jq_test.c +++ b/jq_test.c @@ -24,10 +24,21 @@ static int skipline(const char* buf) { } static void run_jq_tests() { - FILE* testdata = fopen("testdata","r"); + FILE* testdata = NULL; char buf[4096]; int tests = 0, passed = 0; + testdata = fopen("testdata","r"); + if ( NULL == testdata ) + { + /* in an autoconf distcheck, the binary file will be in a _build subdirectory */ + testdata = fopen("../testdata", "r"); + if ( NULL == testdata ) + { + fprintf(stderr, "Could not find testdata file\n"); + exit(1); + } + } while (1) { if (!fgets(buf, sizeof(buf), testdata)) break; if (skipline(buf)) continue; diff --git a/setup.sh b/setup.sh index bb3c26ce..cf360e7d 100755 --- a/setup.sh +++ b/setup.sh @@ -13,7 +13,7 @@ elif [ "superclean" == "$1" ]; then chmod -R u+w jq-${ver} rm -rf jq-${ver} fi - rm -f jq-${ver}.* + rm -f jq-${ver}* fi else autoreconf --install