]> git.draconx.ca Git - dxcommon.git/blobdiff - tests/macros.at
Implement initial test suite.
[dxcommon.git] / tests / macros.at
diff --git a/tests/macros.at b/tests/macros.at
new file mode 100644 (file)
index 0000000..9986d75
--- /dev/null
@@ -0,0 +1,46 @@
+dnl Copyright © 2015 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+AT_BANNER([Autoconf macros])
+
+m4_define([TEST_CONFIGURE_AC], [AT_DATA([configure.ac],
+[[AC_INIT([test], [0])
+]$1[
+AC_OUTPUT
+]])
+cp "$srcdir/install-sh" \
+   "$srcdir/config.guess" \
+   "$srcdir/config.sub" \
+   .
+])
+
+m4_define([TEST_AUTORECONF],
+  [AT_CHECK([autoreconf -I "$srcdir/m4"], [0], [], [stderr])])
+
+m4_define([TEST_CONFIGURE], [AT_CHECK([./configure $1], [0], [ignore])])
+
+dnl Verify that the DX_BASEDIR macro expands correctly during argument
+dnl collection.  Crucially, the output must not contain any other text.
+AT_SETUP([DX_BASEDIR during argument collection])
+
+AT_XFAIL_IF([:])
+
+AT_DATA([test.in],
+[[@TEST@
+]])
+
+TEST_CONFIGURE_AC(
+[[AC@&t@_SUBST([TEST], 'm4@&t@_dquote(DX_BASEDIR)')
+AC_CONFIG_FILES([test])
+]])
+TEST_AUTORECONF
+TEST_CONFIGURE
+
+printf '%s\n' "$srcdir" | sed -e 's:/\./:/:g' -e 's:/\.$::g' \
+                              -e 's:\(.\)//*:\1/:g' >expout
+AT_CHECK([cat test], [0], [expout])
+
+AT_CLEANUP