diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-01-16 15:38:56 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-01-16 15:38:56 +0100 |
commit | 3da9c4c757ff0b6b1df0daf36a8a12274292a9e1 (patch) | |
tree | 27022c1c355127e9e15d826388895f1610b4cc54 | |
parent | 068b2f53579c55365b67619dce4685066cd70a60 (diff) | |
download | automake-3da9c4c757ff0b6b1df0daf36a8a12274292a9e1.tar.gz |
vala: enhance tests
* tests/vala.test: Extend test. Throw in some cosmetic and
consistency changes since we are at it.
* tests/vala5.test: Avoid uselessly requiring libtool. Ensure a
failure happens in case VALAFLAGS are not supported as expected.
Extend test in some ways. Throw in some cosmetic and consistency
changes since we are at it.
* tests/vala-mix.test: New test.
* tests/list-of-tests.mk: Add it.
-rw-r--r-- | tests/list-of-tests.mk | 1 | ||||
-rwxr-xr-x | tests/vala-mix.test | 116 | ||||
-rwxr-xr-x | tests/vala.test | 54 | ||||
-rwxr-xr-x | tests/vala5.test | 48 |
4 files changed, 190 insertions, 29 deletions
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index 9d95e1858..fd095b326 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -873,6 +873,7 @@ vala3.test \ vala4.test \ vala5.test \ vala-vpath.test \ +vala-mix.test \ vars.test \ vars3.test \ vartar.test \ diff --git a/tests/vala-mix.test b/tests/vala-mix.test new file mode 100755 index 000000000..f597a7f87 --- /dev/null +++ b/tests/vala-mix.test @@ -0,0 +1,116 @@ +#! /bin/sh +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Vala sources and C sources in the same program. Functional test. + +required='cc GNUmake' +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AM_PROG_CC_C_O +AM_PROG_VALAC +AC_OUTPUT +END + +cat > Makefile.am <<'END' +bin_PROGRAMS = zardoz mu +AM_VALAFLAGS = --profile=posix +zardoz_SOURCES = foo.vala bar.c +mu_SOURCES = 1.vala 2.c +mu_VALAFLAGS = $(AM_VALAFLAGS) --main=run +mu_CFLAGS = -DHAVE_MU +END + +if cross_compiling; then :; else + unindent >> Makefile.am <<'END' + check-local: + ./zardoz + ./mu + ./zardoz | grep "foo is alive" + ./mu | grep "Howdy, World!" +END +fi + +cat > foo.vala <<'END' +int main () +{ + stdout.printf ("foo is alive\n"); + return 0; +} +END + +echo 'extern int i = 0;' > bar.c + +cat > 1.vala <<'END' +int run () +{ + stdout.printf ("Howdy, World!\n"); + return 0; +} +END + +cat > 2.c <<'END' +#ifdef HAVE_MU +int all_is_ok = 1; +#else +#error "HAVE_MU no defined" +chocke me +#endif +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +./configure + +$MAKE all +ls -l # For debugging. +$MAKE check + +have_generated_files () +{ + test -f mu_vala.stamp + test -f zardoz_vala.stamp + test -f foo.c + test -f 1.c +} + +# Our vala-related rules must create stamp files and intermediate +# C files. +have_generated_files + +$MAKE -q +$MAKE -n | grep stamp && Exit 1 + +# Check the distribution. +$MAKE distcheck + +# Stamp files and intermediate C files should *not* be removed +# by "make clean". +$MAKE clean +have_generated_files + +# But stamp files should be removed by "maintainer-clean" (the +# behaviour w.r.t. intermediate C files is still unclear, and +# better left undefined for the moment). +$MAKE maintainer-clean +ls *vala*.stamp | grep . && Exit 1 + +: diff --git a/tests/vala.test b/tests/vala.test index 3e9ae3648..442661d5d 100755 --- a/tests/vala.test +++ b/tests/vala.test @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009, 2012 Free Software +# Foundation, Inc. # # This file is part of GNU Automake. # @@ -19,21 +19,30 @@ # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. -# Test to make sure intermediate .c files are built from vala source. +# Basic "grepping" test on vala support. -required="libtool" . ./defs || Exit 1 set -e -cat >> 'configure.in' << 'END' +# So that we won't require libtool macros. +cat > acinclude.m4 <<'END' +AC_DEFUN([AC_PROG_LIBTOOL], + [AC_SUBST([LIBTOOL], [:])]) +END + +cat >> configure.in <<'END' AC_PROG_CC +AC_PROG_CXX AC_PROG_LIBTOOL AM_PROG_VALAC +AC_CONFIG_FILES([sub/Makefile]) AC_OUTPUT END -cat > 'Makefile.am' <<'END' +cat > Makefile.am <<'END' +SUBDIRS = sub + bin_PROGRAMS = zardoz zardoz_SOURCES = zardoz.vala zardoz_VALAFLAGS = --debug @@ -42,6 +51,13 @@ lib_LTLIBRARIES = libzardoz.la libzardoz_la_SOURCES = zardoz-foo.vala zardoz-bar.vala END +mkdir sub + +cat > sub/Makefile.am <<'END' +bin_PROGRAMS = foo +foo_SOURCES = bar.vala baz.vala mu.c zap.cxx +END + : > ltmain.sh : > config.sub : > config.guess @@ -49,11 +65,23 @@ END $ACLOCAL $AUTOMAKE -a -grep 'VALAC' Makefile.in -grep 'am_zardoz_OBJECTS' Makefile.in -grep 'am_libzardoz_la_OBJECTS' Makefile.in -grep 'zardoz_vala.stamp' Makefile.in -grep 'libzardoz_la_vala.stamp' Makefile.in -grep 'zardoz\.c' Makefile.in -grep 'zardoz-foo\.c' Makefile.in +grep '\$(VALAC).* \$(AM_VALAFLAGS) \$(VALAFLAGS) ' Makefile.in +grep '\$(VALAC).* \$(zardoz_VALAFLAGS) \$(VALAFLAGS) ' Makefile.in +$FGREP 'am_zardoz_OBJECTS' Makefile.in +$FGREP 'am_libzardoz_la_OBJECTS' Makefile.in +$FGREP 'zardoz_vala.stamp:' Makefile.in +$FGREP 'libzardoz_la_vala.stamp:' Makefile.in +test `$FGREP -c '.stamp:' Makefile.in` -eq 2 +$FGREP 'zardoz.c' Makefile.in +$FGREP 'zardoz-foo.c' Makefile.in +$FGREP 'zardoz-bar.c' Makefile.in + +grep '\$(VALAC).* \$(AM_VALAFLAGS) \$(VALAFLAGS) ' sub/Makefile.in +$FGREP 'foo_VALAFLAGS' sub/Makefile.in && Exit 1 +$FGREP 'am_foo_OBJECTS' sub/Makefile.in +$FGREP 'bar.c' sub/Makefile.in +$FGREP 'baz.c' sub/Makefile.in +$FGREP 'foo_vala.stamp:' sub/Makefile.in +test `$FGREP -c '.stamp:' sub/Makefile.in` -eq 1 +: diff --git a/tests/vala5.test b/tests/vala5.test index 8fc703c4f..2206b255f 100755 --- a/tests/vala5.test +++ b/tests/vala5.test @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009, 2012 Free Software +# Foundation, Inc. # # This file is part of GNU Automake. # @@ -21,54 +21,70 @@ # Test per-target flags. -required="libtool libtoolize pkg-config valac gcc GNUmake" +required="pkg-config valac gcc GNUmake" . ./defs || Exit 1 set -e mkdir src -cat >> 'configure.in' << 'END' +cat >> configure.in <<'END' AC_PROG_CC AM_PROG_CC_C_O -AC_PROG_LIBTOOL AM_PROG_VALAC([0.7.0]) -PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10]) +PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.10]) AC_CONFIG_FILES([src/Makefile]) AC_OUTPUT END -cat > 'Makefile.am' <<'END' +cat > Makefile.am <<'END' SUBDIRS = src END -cat > 'src/Makefile.am' <<'END' +cat > src/Makefile.am <<'END' bin_PROGRAMS = foo bar foo_CFLAGS = $(GOBJECT_CFLAGS) foo_LDADD = $(GOBJECT_LIBS) -foo_SOURCES = baz.vala -bar_SOURCES = baz.vala +foo_SOURCES = xfoo.vala +bar_SOURCES = xbar.vala bar_VALAFLAGS = -D BAR bar_CFLAGS = $(GOBJECT_CFLAGS) bar_LDADD = $(GOBJECT_LIBS) END -cat > 'src/baz.vala' <<'END' -void main () { +cat > src/xfoo.vala <<'END' +int main () +{ + stdout.printf ("foo\n"); + return 0; +} +END + +cat > src/xbar.vala <<'END' +void main () +{ #if BAR stdout.printf ("bar\n"); #else - stdout.printf ("foo\n"); + stdout.oops_an_invalid_method (); #endif } END -libtoolize - $ACLOCAL $AUTOCONF $AUTOMAKE -a -./configure || Exit 77 +grep PKG_CHECK_MODULES configure && skip_ "pkg-config m4 macros not found" + +./configure $MAKE +if cross_compiling; then :; else + ./src/foo + ./src/bar + test `./src/foo` = foo + test `./src/bar` = bar +fi + +: |