]> git.draconx.ca Git - gob-dx.git/commitdiff
Add test cases for various command-line options.
authorNick Bowler <nbowler@draconx.ca>
Tue, 11 Feb 2020 01:27:12 +0000 (20:27 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 14 Feb 2020 05:27:09 +0000 (00:27 -0500)
Looking through the gob2 --help output, add test coverage for most of
the options listed there.  This has revealed several bugs or at least
surprising behaviour, and several of these test cases are currently
xfailing as a result.

Makefile.am
atlocal.in [deleted file]
configure.ac
tests/options.at [new file with mode: 0644]
testsuite.at

index 72e996bdf136b791938ce87c5780de5dba12768b..ae3dae84781afe43bf6e6011e91d1f7c42346732 100644 (file)
@@ -184,4 +184,25 @@ distcheck-hook:
              echo '       *** Remember to update NEWS before preparing a release.'; \
              $(TEST_DISTRIBUTION_OR_ERROR); } >&2
 
+atlocal: config.status
+       $(AM_V_GEN) :; { \
+         printf ': "$${%s=%s}"\n' \
+           CC '$(CC)' \
+           CXX '$(CXX)' \
+           CPPFLAGS '$(CPPFLAGS)' \
+           CFLAGS '$(CFLAGS)' \
+           CXXFLAGS '$(CXXFLAGS)' \
+           LDFLAGS '$(LDFLAGS)' \
+           GTK_CFLAGS '$(GTK_CFLAGS)' \
+           GTK_LIBS '$(GTK_LIBS)' \
+           LIBGOBJECT_CFLAGS '$(LIBGOBJECT_CFLAGS)' \
+           LIBGOBJECT_LIBS '$(LIBGOBJECT_LIBS)' \
+           HAVE_GOBJECT '$(HAVE_GOBJECT)' \
+           HAVE_GTK2 '$(HAVE_GTK2)' \
+           pkgdatadir '$(pkgdatadir)' \
+           ; } >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+check_DATA = atlocal
+CLEANFILES += atlocal
+
 include $(top_srcdir)/common/snippet/autotest.mk
diff --git a/atlocal.in b/atlocal.in
deleted file mode 100644 (file)
index d169bd9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-: "${CC=@CC@}"
-: "${CXX=@CXX@}"
-: "${CPPFLAGS=@CPPFLAGS@}"
-: "${CFLAGS=@CFLAGS@}"
-: "${CXXFLAGS=@CXXFLAGS@}"
-: "${LDFLAGS=@LDFLAGS@}"
-: "${GTK_CFLAGS=@GTK_CFLAGS@}"
-: "${GTK_LIBS=@GTK_LIBS@}"
-: "${LIBGOBJECT_CFLAGS=@LIBGOBJECT_CFLAGS@}"
-: "${LIBGOBJECT_LIBS=@LIBGOBJECT_LIBS@}"
-: "${HAVE_GOBJECT=@HAVE_GOBJECT@}"
-: "${HAVE_GTK2=@HAVE_GTK2@}"
index b43fc7c047c0fc3fc89353573fd070b845f93a72..3632fb15767e4e5fff09dd2e20467d5d60be7a33 100644 (file)
@@ -40,5 +40,5 @@ AC_CONFIG_TESTDIR([.], [t:.])
 DX_PROG_AUTOTEST
 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
 
-AC_CONFIG_FILES([Makefile gob2.spec doc/gob2.1 atlocal])
+AC_CONFIG_FILES([Makefile gob2.spec doc/gob2.1])
 AC_OUTPUT
diff --git a/tests/options.at b/tests/options.at
new file mode 100644 (file)
index 0000000..2f85019
--- /dev/null
@@ -0,0 +1,613 @@
+dnl Copyright © 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.
+
+dnl Check that the --help option exits successfully and prints only to
+dnl standard output.
+AT_SETUP([--help option])
+AT_KEYWORDS([option])dnl
+
+# Currently prints to standard error :(
+AT_XFAIL_IF([:])
+AT_CHECK([gob2 invalid-file.gob --help --invalid-option], [0], [ignore-nolog])
+
+AT_CLEANUP
+
+dnl Check that the --version option exits successfully, prints only to
+dnl standard output, and contains the correct version number.
+AT_SETUP([--version option])
+AT_KEYWORDS([option])dnl
+
+# Currently prints to standard error :(
+AT_XFAIL_IF([:])
+AT_CHECK([gob2 invalid-file.gob --version --invalid-option], [0], [stdout])
+AT_CHECK([awk 'NR == 1 { print $NF }' stdout], [0], [AT_PACKAGE_VERSION
+])
+
+AT_CLEANUP
+
+AT_SETUP([--exit-on-warn option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  private int x;
+  /* gob produces a warning due to override and nick combination */
+  property INT x ( override, nick = "hello", link );
+}
+]])
+
+AT_CHECK([gob2 test.gob], [0], [], [ignore])
+AT_CHECK([gob2 test.gob --exit-on-warn], [1], [], [ignore])
+AT_CHECK([gob2 test.gob --no-exit-on-warn -w], [1], [], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([--no-exit-on-warn option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  private int x;
+  /* gob produces a warning due to override and nick combination */
+  property INT x ( override, nick = "hello", link );
+}
+]])
+
+AT_CHECK([gob2 test.gob], [0], [], [ignore])
+AT_CHECK([gob2 test.gob --exit-on-warn], [1], [], [ignore])
+AT_CHECK([gob2 test.gob -w --no-exit-on-warn], [0], [], [ignore])
+AT_CHECK([gob2 test.gob --exit-on-warn --no-exit-on-warn], [0], [], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([--ondemand-private-header option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([priv.gob], [[class A:B:C from G:Object {
+  private int x;
+}
+%{
+TEST_WITNESS_C
+%}
+%h{
+TEST_WITNESS_H
+%}
+%privateheader{
+TEST_WITNESS_PRIVATE
+%}
+]])
+sed '/private int/d' priv.gob >nopriv.gob
+
+rm -f *.c *.h
+AT_CHECK([gob2 nopriv.gob])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([test ! -f a-b-c-private.h])
+
+rm -f *.c *.h
+AT_CHECK([gob2 priv.gob])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c-private.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+rm -f *.c *.h
+AT_CHECK([gob2 nopriv.gob --always-private-header --ondemand-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([test ! -f a-b-c-private.h])
+
+rm -f *.c *.h
+AT_CHECK([gob2 priv.gob --no-private-header --ondemand-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c-private.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+AT_CLEANUP
+
+AT_SETUP([--always-private-header option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([priv.gob], [[class A:B:C from G:Object {
+  private int x;
+}
+%{
+TEST_WITNESS_C
+%}
+%h{
+TEST_WITNESS_H
+%}
+%privateheader{
+TEST_WITNESS_PRIVATE
+%}
+]])
+sed '/private int/d' priv.gob >nopriv.gob
+
+rm -f *.c *.h
+AT_CHECK([gob2 nopriv.gob --always-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c-private.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+rm -f *.c *.h
+AT_CHECK([gob2 priv.gob --no-private-header --always-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c-private.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+rm -f *.c *.h
+AT_CHECK([gob2 nopriv.gob --ondemand-private-header --always-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c-private.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+AT_CLEANUP
+
+AT_SETUP([--no-private-header option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([priv.gob], [[class A:B:C from G:Object {
+  private int x;
+}
+%{
+TEST_WITNESS_C
+%}
+%h{
+TEST_WITNESS_H
+%}
+%privateheader{
+TEST_WITNESS_PRIVATE
+%}
+]])
+sed '/private int/d' priv.gob >nopriv.gob
+
+rm -f *.c *.h
+AT_CHECK([gob2 priv.gob --no-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([test ! -f a-b-c-private.h])
+
+rm -f *.c *.h
+AT_CHECK([gob2 nopriv.gob --always-private-header --no-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([test ! -f a-b-c-private.h])
+
+rm -f *.c *.h
+AT_CHECK([gob2 priv.gob --ondemand-private-header --no-private-header])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a-b-c.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([test ! -f a-b-c-private.h])
+
+AT_CLEANUP
+
+AT_SETUP([--file-sep option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class A:B:C from G:Object {
+}
+%{
+TEST_WITNESS_C
+%}
+%h{
+TEST_WITNESS_H
+%}
+%privateheader{
+TEST_WITNESS_PRIVATE
+%}
+]])
+
+mkdir a; mkdir a/b
+AT_CHECK([gob2 test.gob --file-sep=/])
+AT_CHECK([grep '^TEST_WITNESS' a/b/c.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' a/b/c.h], [0], [TEST_WITNESS_H
+])
+
+AT_CHECK([gob2 test.gob --always-private-header --file-sep=])
+AT_CHECK([grep '^TEST_WITNESS' abc.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' abc.h], [0], [TEST_WITNESS_H
+])
+AT_CHECK([grep '^TEST_WITNESS' abcprivate.h], [0], [TEST_WITNESS_PRIVATE
+])
+
+rm -f abc*
+AT_CHECK([gob2 test.gob --file-sep])
+AT_CHECK([grep '^TEST_WITNESS' abc.c], [0], [TEST_WITNESS_C
+TEST_WITNESS_PRIVATE
+])
+AT_CHECK([grep '^TEST_WITNESS' abc.h], [0], [TEST_WITNESS_H
+])
+
+AT_CLEANUP
+
+AT_SETUP([--output-dir option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class A:B:C from G:Object {
+}
+%{
+TEST_WITNESS_C
+%}
+%h{
+TEST_WITNESS_H
+%}
+]])
+
+mkdir output-dir o
+AT_CHECK([gob2 test.gob --output-dir=output-dir])
+AT_CHECK([grep '^TEST_WITNESS' output-dir/a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' output-dir/a-b-c.h], [0], [TEST_WITNESS_H
+])
+
+AT_CHECK([gob2 test.gob -o o])
+AT_CHECK([grep '^TEST_WITNESS' o/a-b-c.c], [0], [TEST_WITNESS_C
+])
+AT_CHECK([grep '^TEST_WITNESS' o/a-b-c.h], [0], [TEST_WITNESS_H
+])
+
+AT_CLEANUP
+
+dnl Check that the --no-touch option does not modify any files that would be
+dnl unchanged by gob, and that the --no-touch-headers option does not modify
+dnl any header files.
+m4_foreach([OPTION], [[[--no-touch]], [[--no-touch-headers]]],
+[AT_SETUP([OPTION option])
+AT_KEYWORDS([option])dnl
+
+# Sanity check for make implementation
+touch test.h; touch test-h
+AT_CHECK([mtime_uptodate test-h test.h || exit 77])
+TEST_MTIME_DELAY; touch test.h
+AT_CHECK([mtime_uptodate test-h test.h && exit 77], [1])
+rm -f test.h
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  private int x;
+}
+]])
+
+m4_if(OPTION, [--no-touch-headers],
+[#Currently, the private header is modified even with --no-touch-headers.
+AT_XFAIL_IF([:])])dnl
+
+AT_CHECK([gob2 test.gob])
+touch test-c test-h test-private
+TEST_MTIME_DELAY
+AT_CHECK([gob2 test.gob])
+AT_CHECK([mtime_uptodate test-c test.c], [1])
+AT_CHECK([mtime_uptodate test-h test.h], [1])
+AT_CHECK([mtime_uptodate test-private test-private.h], [1])
+
+touch test-c test-h test-private
+TEST_MTIME_DELAY
+AT_CHECK([gob2 test.gob OPTION])
+AT_CHECK([mtime_uptodate test-c test.c],
+  m4_if(OPTION, [--no-touch], [0], [1]))
+AT_CHECK([mtime_uptodate test-h test.h], [0])
+AT_CHECK([mtime_uptodate test-private test-private.h], [0])
+
+cat >>test.gob <<'EOF'
+%{
+/* some code */
+%}
+EOF
+touch test-c test-h test-private
+TEST_MTIME_DELAY
+AT_CHECK([gob2 test.gob OPTION])
+AT_CHECK([mtime_uptodate test-c test.c], [1])
+AT_CHECK([mtime_uptodate test-h test.h], [0])
+AT_CHECK([mtime_uptodate test-private test-private.h], [0])
+
+cat >>test.gob <<'EOF'
+%h{
+/* yonder comment */
+%}
+EOF
+touch test-c test-h test-private
+TEST_MTIME_DELAY
+AT_CHECK([gob2 test.gob OPTION])
+AT_CHECK([mtime_uptodate test-c test.c],
+  m4_if(OPTION, [--no-touch], [0], [1]))
+AT_CHECK([mtime_uptodate test-h test.h], [1])
+AT_CHECK([mtime_uptodate test-private test-private.h], [0])
+
+cat >>test.gob <<'EOF'
+%privateheader{
+/* once more unto the breach */
+%}
+EOF
+touch test-c test-h test-private
+TEST_MTIME_DELAY
+AT_CHECK([gob2 test.gob OPTION])
+AT_CHECK([mtime_uptodate test-c test.c],
+  m4_if(OPTION, [--no-touch], [0], [1]))
+AT_CHECK([mtime_uptodate test-h test.h], [0])
+AT_CHECK([mtime_uptodate test-private test-private.h], [1])
+
+AT_CLEANUP
+])
+
+AT_SETUP([--no-write option])
+AT_KEYWORDS([option])dnl
+
+mkdir outdir
+AT_DATA([outdir/test.gob], [[class :Test from G:Object
+{
+  private int x;
+}
+]])
+AT_CHECK([cd outdir && ls -Al], [0], [stdout-nolog])
+mv -f stdout expout
+
+AT_CHECK([cd outdir && gob2 test.gob --no-write && ls -Al], [0], [expout])
+AT_CHECK([cd outdir && gob2 test.gob -n && ls -Al], [0], [expout])
+
+AT_CHECK([cd outdir && gob2 test.gob && ls -Al], [0], [stdout-nolog])
+mv -f stdout expout
+
+AT_CHECK([cd outdir && gob2 test.gob --no-write && ls -Al], [0], [expout])
+AT_CHECK([cd outdir && gob2 test.gob -n && ls -Al], [0], [expout])
+
+AT_CLEANUP
+
+AT_SETUP([--no-extern-c option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  private int x;
+}
+]])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([cat *.h | grep 'extern "C"'], [0], [extern "C" {
+extern "C" {
+])
+
+AT_CHECK([gob2 --no-extern-c test.gob])
+AT_CHECK([cat *.h | grep 'extern "C"'], [1])
+
+AT_CLEANUP
+
+AT_SETUP([--no-gnu option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[enum TEST_ENUM {
+  TEST_ENUM_A
+} Test:Enum;
+
+flags TEST_FLAGS {
+  TEST_FLAG_A
+} Test:Flags;
+
+error TEST_ERROR {
+  TEST_ERROR_A
+} Test:Error;
+
+class :Test from G:Object
+{
+  private int x;
+}
+]])
+
+# --no-gnu is currently busted for the get_type function declaration.
+AT_XFAIL_IF([:])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([cat test*.h test.c | grep '_GNUC_' >/dev/null], [0])
+
+AT_CHECK([gob2 --no-gnu test.gob])
+AT_CHECK([cat test*.h test.c | grep '_GNUC_'], [1])
+
+AT_CLEANUP
+
+dnl Check that --no-self-alias works as documented.  The self_xxx method
+dnl aliases are not documented to be affected by this option, so check that
+dnl they are unaffected.
+AT_SETUP([--no-self-alias option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  public void myfunction(self) { };
+}
+]])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([:; { grep '#define.*SELF' test.c &&
+grep 'typedef.*Self' test.c &&
+grep '#define.*self_myfunction' test.c; } >/dev/null], [0])
+
+AT_CHECK([gob2 --no-self-alias test.gob])
+AT_CHECK([grep '#.*define.*SELF' test.c], [1])
+AT_CHECK([grep 'typedef.*Self' test.c], [1])
+AT_CHECK([grep '#define.*self_myfunction' test.c >/dev/null], [0])
+
+AT_CLEANUP
+
+AT_SETUP([--no-lines option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  public int foo(void) { return 42; }
+  private int x;
+}
+]])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([cat test.h test-private.h test.c | grep '#.*line' >/dev/null])
+
+AT_CHECK([gob2 --no-lines test.gob])
+AT_CHECK([cat test.h test-private.h test.c | grep '#.*line'], [1])
+
+AT_CLEANUP
+
+dnl Check that the --no-kill-underscores option is ignored for compatibility.
+AT_SETUP([--no-kill-underscores option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+}
+]])
+
+mkdir orig
+AT_CHECK([gob2 --output-dir orig test.gob])
+AT_CHECK([gob2 --no-kill-underscores test.gob])
+
+cp -f orig/test.c expout
+AT_CHECK([cat test.c], [0], [expout])
+
+cp -f orig/test.h expout
+AT_CHECK([cat test.h], [0], [expout])
+
+AT_CLEANUP
+
+AT_SETUP([--always-private-struct option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+{
+  public int my_public_member;
+}
+]])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([sed -n '/my_public_member/,/^}/s/_priv/&/p' test.h])
+
+AT_CHECK([gob2 --always-private-struct test.gob])
+AT_CHECK([sed -n '/my_public_member/,/^}/s/[[  ]]*\(.*_priv;\)/\1/p' test.h],
+  [0], [TestPrivate *_priv;
+])
+
+AT_CLEANUP
+
+dnl Check the --gtk3 option.  The only effect of this option seems to be to
+dnl change the normal "Iface" suffix on interface types to "Interface".  So
+dnl let's make sure that behaviour is tested.
+AT_SETUP([--gtk3 option])
+AT_KEYWORDS([option])dnl
+
+AT_DATA([test.gob], [[class :Test from G:Object
+  (interface Gtk:Actionable)
+{
+}
+]])
+
+AT_CHECK([gob2 test.gob])
+AT_CHECK([sed -n \
+  's/.*Gtk_Actionable_init.*\(GtkActionable[[^ *]]*\).*/\1/p' test.c], [0],
+  [GtkActionableIface
+])
+
+AT_CHECK([gob2 --gtk3 test.gob])
+AT_CHECK([sed -n \
+  's/.*Gtk_Actionable_init.*\(GtkActionable[[^ *]]*\).*/\1/p' test.c], [0],
+  [GtkActionableInterface
+])
+
+AT_CLEANUP
+
+AT_SETUP([--m4-dir option])
+AT_KEYWORDS([option])dnl
+AT_CHECK_UNQUOTED([gob2 --m4-dir], [0], [$pkgdatadir/m4
+])
+AT_CLEANUP
+
+dnl Check that the --m4 option shells out to m4 and passes through
+dnl all remaining arguments.
+AT_SETUP([--m4 option])
+AT_KEYWORDS([option])dnl
+
+mkdir bin
+AT_DATA([bin/m4], [[#!/bin/sh
+test $][# != 0 && printf '%s\n' "$][*" >&2
+cat <<'EOF'
+class M4:Test from G:Object
+{
+}
+EOF
+]])
+chmod +x bin/m4
+
+PATH=$PWD/bin${PATH:+":$PATH"}
+AT_CHECK([gob2 --m4 filename], [0], [], [stderr])
+read gob_m4_args <stderr
+AT_CHECK([test -f m4-test.c])
+
+rm -f m4-test.c m4-test.h
+cat >experr <<EOF
+$gob_m4_args --help I am trapped in a test case factory --
+EOF
+AT_CHECK([gob2 --m4 filename --help I am trapped in a test case factory --],
+  [0], [], [experr])
+AT_CHECK([test -f m4-test.c])
+
+AT_CLEANUP
+
+dnl Check that the --m4 option shells out to m4 and passes through
+dnl all remaining arguments without adding any additional arguments.
+AT_SETUP([--m4-clean option])
+AT_KEYWORDS([option])dnl
+
+mkdir bin
+AT_DATA([bin/m4], [[#!/bin/sh
+test $][# != 0 && printf '%s\n' "$][*" >&2
+cat <<'EOF'
+class M4:Test from G:Object
+{
+}
+EOF
+]])
+chmod +x bin/m4
+
+PATH=$PWD/bin${PATH:+":$PATH"}
+AT_CHECK([gob2 --m4-clean filename], [0], [], [filename
+])
+AT_CHECK([test -f m4-test.c])
+
+rm -f m4-test.c m4-test.h
+AT_CHECK(
+  [gob2 --m4-clean filename --help I am trapped in a test case factory --],
+  [0], [], [filename --help I am trapped in a test case factory --
+])
+AT_CHECK([test -f m4-test.c])
+
+AT_CLEANUP
index c87123b9fd61150ccc0cb25f8d78e452e5ccb28e..025e78f000f542fdf5853dd897edf1edf8d022ab 100644 (file)
@@ -3,6 +3,36 @@ License GPLv2+: GNU General Public License version 2 or any later version.
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.])
 
+dnl mtime_uptodate file-a file-b: returns success iff file-a's modification
+dnl time is at least as new as file-b's.
+m4_divert_push([PREPARE_TESTS])dnl
+mtime_uptodate () {
+  cat >mtime-uptodate.mk <<EOF
+$1: $2
+       false
+EOF
+  $MAKE -f mtime-uptodate.mk >/dev/null 2>&1 || return 1
+}
+m4_divert_pop([PREPARE_TESTS])
+
+dnl TEST_MTIME_DELAY
+dnl
+dnl Delay script execution such that file modifications done prior to the
+dnl delay will have older timestamps than file modifications performed after
+dnl the delay.
+dnl
+dnl Some filesystems have insufficient timestamp resolution (or maybe
+dnl computers are just too fast) to reliably distinguish between back-to-back
+dnl file modification.
+dnl
+dnl This delay is implemented by repeatingly touching files until a different
+dnl timestamp is produced.
+m4_define([TEST_MTIME_DELAY],
+[touch mtime-delay.old; touch mtime-delay.new
+while mtime_uptodate mtime-delay.old mtime-delay.new; do
+  touch mtime-delay.new
+done])
+
 dnl Compile a C source file with default cflags for libgobject.  The test
 dnl group is skipped if libgobject was not enabled at configure time.  The
 dnl first argument contains extra compiler flags, which must include the
@@ -63,8 +93,14 @@ CPPFLAGS="-I$builddir $CPPFLAGS"
   command -v $AUTOCONF
   (set -x; $AUTOCONF --version) 2>&1
   echo
+  AS_UNSET([MAKEFLAGS])
+  AS_ECHO(["MAKE = ${MAKE=make}"])
+  command -v $MAKE
+  (set -x; $MAKE --version) 2>&1
+  echo
 } >&AS_MESSAGE_LOG_FD
 m4_divert_pop([PREPARE_TESTS])
 
 m4_include([tests/general.at])
+m4_include([tests/options.at])
 m4_include([tests/interface.at])