]> git.draconx.ca Git - gob-dx.git/blob - testsuite.at
Minor testsuite cleanup.
[gob-dx.git] / testsuite.at
1 AT_COPYRIGHT([Copyright © 2019-2020 Nick Bowler
2 License GPLv2+: GNU General Public License version 2 or any later version.
3 This is free software: you are free to change and redistribute it.
4 There is NO WARRANTY, to the extent permitted by law.])
5
6 dnl Compile a C source file with default cflags for libgobject.  The test
7 dnl group is skipped if libgobject was not enabled at configure time.  The
8 dnl first argument contains extra compiler flags, which must include the
9 dnl source file name.  The remaining arguments correspond to the remaining
10 dnl arguments of AT_CHECK (e.g., the 2nd argument to TEST_COMPILE_GOBJECT
11 dnl is the 2nd argument of AT_CHECK -- the expected exit status).
12 m4_define([TEST_COMPILE_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
13 $CC $CPPFLAGS $CFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
14
15 dnl Same as TEST_COMPILE_GOBJECT, except that the C++ compiler is used.
16 m4_define([TEST_COMPILEXX_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
17 $CXX $CPPFLAGS $CXXFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
18
19 dnl TEST_CLASSNAME_REPLACE_SEP(Class:Name, separator)
20 dnl
21 dnl Convert the components of Class:Name to lower case, and join them
22 dnl together with the given separator.  The result is a quoted string.
23 m4_define([TEST_CLASSNAME_REPLACE_SEP],
24   [m4_join([$2], m4_unquote(m4_split(m4_tolower([$1]), [:])))])
25
26 dnl TEST_TYPE_MODULE(Class:Name)
27 dnl Create a GTypeModule (Class:Name:Mod) which registers the dynamic
28 dnl type indiciated by Class:Name.
29 m4_define([TEST_TYPE_MODULE],
30 [TEST_TYPE_MODULE_([$1],
31   TEST_CLASSNAME_REPLACE_SEP([$1], [_]),
32   TEST_CLASSNAME_REPLACE_SEP([$1], [-]))])
33
34 m4_define([TEST_TYPE_MODULE_],
35 [AT_KEYWORDS([dynamic])dnl
36
37 AT_DATA([$3-mod.gob], [[%{
38 #include "$3.h"
39 %}
40 class $1:Mod from G:Type:Module
41 {
42   override (G:Type:Module) gboolean load(G:Type:Module *m)
43   {
44     $2_register_type(m);
45     return TRUE;
46   }
47 }
48 ]])
49 AT_CHECK([gob2 $3-mod.gob])
50 TEST_COMPILE_GOBJECT([$3-mod.c], [0], [], [ignore])])
51
52 AT_INIT
53 AT_COLOR_TESTS
54
55 AT_TESTED([gob2])
56 m4_divert_push([PREPARE_TESTS])dnl
57 :; {
58   AS_ECHO(["AUTOCONF = ${AUTOCONF=autoconf}"])
59   command -v $AUTOCONF
60   (set -x; $AUTOCONF --version) 2>&1
61   echo
62 } >&AS_MESSAGE_LOG_FD
63 m4_divert_pop([PREPARE_TESTS])
64
65 m4_include([tests/general.at])
66 m4_include([tests/interface.at])