]> git.draconx.ca Git - gob-dx.git/commitdiff
Add a test case which runs the GOB2_CHECK macro.
authorNick Bowler <nbowler@draconx.ca>
Mon, 27 Jan 2020 22:46:19 +0000 (17:46 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 27 Jan 2020 23:06:10 +0000 (18:06 -0500)
The shipped macro is actually busted because the version in this git
repo is 2.0.20a and the --version output parsing explodes badly.

Before fixing the macro, let's add a test which runs a basic test of
the macro against the just-compiled gob2 version.

tests/general.at
testsuite.at

index 9e5fbccd8b36ccb61d58db7eb1dc29d8ac328e93..10f6f0fc7962c14de29b08ffae4e1cccf14af29e 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2019 Nick Bowler
+dnl Copyright © 2019-2020 Nick Bowler
 dnl License GPLv2+: GNU General Public License version 2 or any later version.
 dnl This is free software: you are free to change and redistribute it.
 dnl There is NO WARRANTY, to the extent permitted by law.
@@ -266,3 +266,47 @@ AT_CHECK([./main], [0], [Hello, World!
 ])
 
 AT_CLEANUP
+
+AT_SETUP([GOB2_CHECK min-version test])
+
+AT_DATA([configure.ac],
+[[AC_PREREQ([2.62])
+AC_INIT([test], [0])
+AC_OUTPUT
+]])
+AT_CHECK([$AUTOCONF && test -f configure || exit 77], [0], [ignore], [ignore])
+
+m4_define([MYVER],
+  m4_bpatsubst(m4_dquote(m4_defn([AT_PACKAGE_VERSION])), [[^][0-9.]]))
+m4_if(m4_defn([MYVER]), m4_defn([AT_PACKAGE_VERSION]), [], [AT_XFAIL_IF([:])])
+
+m4_define([MYVER_P1], m4_dquote(m4_reverse(m4_unquote(
+  m4_split(m4_defn([MYVER]), [[.]])))))
+m4_define([MYVER_P1], m4_join([.], m4_reverse(
+  m4_eval(m4_car(MYVER_P1)+1), m4_shift(MYVER_P1))))
+
+AT_DATA([test.in], [[@GOB2@
+]])
+
+cat >configure.ac <<EOF
+[m4@&t@_include([$srcdir/gob2.m4])]
+[m4@&t@_pattern_forbid([^GOB2_])]
+[AC_INIT([gob2_check], [0])]
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER]))[)]
+GOB2=\`command -v \$GOB2\`
+[AC_CONFIG_FILES([test])]
+[AC_OUTPUT]
+EOF
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [0], [ignore])
+
+command -v gob2 >expout
+AT_CHECK([cat test], [0], [expout], [ignore])
+
+sed '/GOB2_CHECK/c\
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER_P1]))[)]' configure.ac >configure.new
+mv -f configure.new configure.ac
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [1], [ignore], [ignore])
+
+AT_CLEANUP
index 97c0253463c51a20370b9b4a8d1d0806711e8ba9..fccacb4a823c32e2816d3ec28fc620da55039163 100644 (file)
@@ -20,5 +20,13 @@ AT_INIT
 AT_COLOR_TESTS
 
 AT_TESTED([gob2])
+m4_divert_push([PREPARE_TESTS])dnl
+:; {
+  AS_ECHO(["AUTOCONF = ${AUTOCONF=autoconf}"])
+  command -v $AUTOCONF
+  (set -x; $AUTOCONF --version) 2>&1
+  echo
+} >&AS_MESSAGE_LOG_FD
+m4_divert_pop([PREPARE_TESTS])
 
 m4_include([tests/general.at])