]> git.draconx.ca Git - dxcommon.git/blob - tests/macros.at
f57ecae23976626ab7e9e8f49effb446dfff2746
[dxcommon.git] / tests / macros.at
1 dnl Copyright © 2015 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 AT_BANNER([Autoconf macros])
8
9 m4_define([TEST_CONFIGURE_AC], [AT_DATA([configure.ac],
10 [[AC_INIT([test], [0])
11 ]$1[
12 AC_OUTPUT
13 ]])
14 cp "$srcdir/install-sh" \
15    "$srcdir/config.guess" \
16    "$srcdir/config.sub" \
17    .
18 ])
19
20 m4_define([TEST_AUTORECONF],
21   [AT_CHECK([autoreconf -I "$srcdir/m4"], [0], [], [stderr])])
22
23 m4_define([TEST_CONFIGURE], [AT_CHECK([./configure $1], [0], [ignore])])
24
25 dnl Verify that the DX_BASEDIR macro expands correctly during argument
26 dnl collection.  Crucially, the output must not contain any other text.
27 AT_SETUP([DX_BASEDIR during argument collection])
28
29 AT_DATA([test.in],
30 [[@TEST@
31 ]])
32
33 TEST_CONFIGURE_AC(
34 [[AC_SUBST([TEST], 'm4@&t@_dquote(DX_BASEDIR)')
35 AC_CONFIG_FILES([test])
36 ]])
37 TEST_AUTORECONF
38 TEST_CONFIGURE
39
40 printf '%s\n' "$srcdir" | sed -e 's:/\./:/:g' -e 's:/\.$::g' \
41                               -e 's:\(.\)//*:\1/:g' >expout
42 AT_CHECK([cat test], [0], [expout])
43
44 AT_CLEANUP
45
46 dnl Verify that DX_BASEDIR is correctly AC_SUBSTed
47 AT_SETUP([DX_BASEDIR output substitution])
48
49 AT_DATA([test.in],
50 [[@DX_BASEDIR@
51 ]])
52
53 TEST_CONFIGURE_AC(
54 [[DX_INIT
55 AC_CONFIG_FILES([test])
56 ]])
57 TEST_AUTORECONF
58 TEST_CONFIGURE
59
60 printf '%s\n' "$srcdir" | sed -e 's:/\./:/:g' -e 's:/\.$::g' \
61                               -e 's:\(.\)//*:\1/:g' >expout
62 AT_CHECK([cat test], [0], [expout])
63
64 AT_CLEANUP
65
66 dnl Verify that DX_BASEDIR is set correctly implicitly
67 AT_SETUP([DX_BASEDIR implicit definition])
68
69 AT_DATA([test.in],
70 [[@DX_BASEDIR@
71 ]])
72
73 TEST_CONFIGURE_AC(
74 [[DX_EXPORTED_SH
75 AC_CONFIG_FILES([test])
76 ]])
77 TEST_AUTORECONF
78 TEST_CONFIGURE
79
80 AT_CLEANUP