diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/Makefile.in | 21 | ||||
-rw-r--r-- | tests/defs | 5 | ||||
-rwxr-xr-x | tests/java-clean.test | 68 | ||||
-rwxr-xr-x | tests/java-compile-install.test | 99 | ||||
-rwxr-xr-x | tests/java-compile-run-flat.test | 241 | ||||
-rwxr-xr-x | tests/java-compile-run-nested.test | 254 | ||||
-rwxr-xr-x | tests/java-mix.test | 69 | ||||
-rwxr-xr-x | tests/java-no-duplicate.test | 47 | ||||
-rwxr-xr-x | tests/java-nobase.test | 67 | ||||
-rwxr-xr-x | tests/java-noinst.test | 38 | ||||
-rwxr-xr-x | tests/java-rebuild.test | 126 | ||||
-rwxr-xr-x | tests/java-sources.test | 67 | ||||
-rwxr-xr-x | tests/java-uninstall.test | 101 | ||||
-rwxr-xr-x | tests/java.test | 6 | ||||
-rwxr-xr-x | tests/javaflags.test | 62 | ||||
-rwxr-xr-x | tests/javaprim.test | 5 | ||||
-rwxr-xr-x | tests/javasubst.test | 5 | ||||
-rw-r--r-- | tests/list-of-tests.mk | 20 | ||||
-rw-r--r-- | tests/nobase-nodist.test | 62 | ||||
-rwxr-xr-x | tests/py-compile-basedir.test | 51 | ||||
-rwxr-xr-x | tests/py-compile-basic.test | 64 | ||||
-rwxr-xr-x | tests/py-compile-basic2.test | 71 | ||||
-rwxr-xr-x | tests/py-compile-destdir.test | 44 | ||||
-rwxr-xr-x | tests/py-compile-env.test | 60 | ||||
-rwxr-xr-x | tests/py-compile-option-terminate.test | 44 | ||||
-rwxr-xr-x | tests/py-compile-usage.test | 75 |
27 files changed, 1751 insertions, 22 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index f502f8d4d..1e4b6d544 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,6 +45,7 @@ all.test \ cond17.test \ gcj6.test \ override-conditional-2.test \ +java-nobase.test \ pr8365-remake-timing.test \ yacc-dist-nobuild-subdir.test \ vala-vpath.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 77f5cdd7a..6de6c109d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -312,6 +312,7 @@ all.test \ cond17.test \ gcj6.test \ override-conditional-2.test \ +java-nobase.test \ pr8365-remake-timing.test \ yacc-dist-nobuild-subdir.test \ vala-vpath.test \ @@ -762,12 +763,23 @@ interp2.test \ java.test \ java2.test \ java3.test \ +javaflags.test \ java-check.test \ +java-clean.test \ +java-compile-install.test \ +java-compile-run-flat.test \ +java-compile-run-nested.test \ java-empty-classpath.test \ javaprim.test \ javasubst.test \ java-extra.test \ +java-mix.test \ +java-no-duplicate.test \ +java-nobase.test \ java-noinst.test \ +java-rebuild.test \ +java-sources.test \ +java-uninstall.test \ ldadd.test \ ldflags.test \ lex.test \ @@ -895,6 +907,7 @@ no-outdir-option.test \ nobase.test \ nobase-libtool.test \ nobase-python.test \ +nobase-nodist.test \ nodef.test \ nodef2.test \ nodep.test \ @@ -1059,6 +1072,14 @@ primary-prefix-couples-force-valid.test \ primary-prefix-couples-documented-valid.test \ proginst.test \ programs-primary-rewritten.test \ +py-compile-basedir.test \ +py-compile-basic.test \ +py-compile-basic2.test \ +py-compile-destdir.test \ +py-compile-env.test \ +py-compile-option-terminate.test \ +py-compile-usage.test \ +python-dist.test \ python.test \ python2.test \ python3.test \ diff --git a/tests/defs b/tests/defs index 297e5c0df..e5f66a52a 100644 --- a/tests/defs +++ b/tests/defs @@ -703,6 +703,11 @@ do echo "$me: running javac -version -help" javac -version -help || skip_all_ "Sun Java compiler not available" ;; + java) + # See the comments above about `javac' for why we use also `-help'. + echo "$me: running java -version -help" + java -version -help || skip_all_ "Sun Java interpreter not found" + ;; makedepend) echo "$me: running makedepend -f-" makedepend -f- \ diff --git a/tests/java-clean.test b/tests/java-clean.test new file mode 100755 index 000000000..7db5e5371 --- /dev/null +++ b/tests/java-clean.test @@ -0,0 +1,68 @@ +#! /bin/sh +# Copyright (C) 1998, 2001, 2002, 2004, 2007 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/>. + +# Test cleaning of Java class files and timestamps. + +required=javac +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +javadir = $(datadir)/java + +java_JAVA = Class.java +dist_java_JAVA = ClassDist.java +nodist_java_JAVA = ClassNodist.java + +nobase_java_JAVA = ClassNobase.java +nobase_dist_java_JAVA = ClassNobaseDist.java +nobase_nodist_java_JAVA = ClassNobaseNodist.java +END + +for base in '' Nobase; do + for dist in '' Dist Nodist; do + echo "class Class$base$dist {}" > Class$base$dist.java + done +done + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE +ls -l +test -f classjava.stamp +for base in '' Nobase; do + for dist in '' Dist Nodist; do + test -f Class$base$dist.class + done +done +$MAKE clean +find . -name '*.class' -o -name '*.stamp' | grep . && Exit 1 +# We should not remove unrelated stamp files. +echo timestamp > classjava2.stamp +echo timestamp > classdist_java.stamp +$MAKE clean +test -f classjava2.stamp +test -f classdist_java.stamp + +: diff --git a/tests/java-compile-install.test b/tests/java-compile-install.test new file mode 100755 index 000000000..74b7a001f --- /dev/null +++ b/tests/java-compile-install.test @@ -0,0 +1,99 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test on compilation and installation of Java class files. + +required=javac +. ./defs || Exit 1 + +set -e + +cat >>configure.in <<'EOF' +AC_OUTPUT +EOF + +cat > Makefile.am << 'END' +javadir = $(datadir)/java +java_JAVA = Foo.java +nobase_java_JAVA = Foo2.java +nobase_dist_java_JAVA = Bar.java +nodist_java_JAVA = Baz.java + +# Java files are not distributed by default, so we distribute +# one "by hand" ... +EXTRA_DIST = Foo.java +# ... and make the other one generated. +Foo2.java: + rm -f $@ $@-t + echo 'class bClass {}' > $@-t + chmod a-w $@-t && mv -f $@-t $@ + +# Explicitly declared as `nodist_', so generate it. +Baz.java: + rm -f $@ $@-t + echo 'class Baz {}' > $@-t + echo 'class Baz2 {}' >> $@-t + chmod a-w $@-t && mv -f $@-t $@ + +test: + ls -l $(srcdir) . ;: For debugging. + test -f $(srcdir)/Foo.java + test -f $(srcdir)/Bar.java + test -f Foo2.java + test -f Baz.java + test -f aClass.class + test -f bClass.class + test -f Zardoz.class + test -f Baz.class + test -f Baz2.class + test ! -r Foo.class + test ! -r Bar.class + test -f classjava.stamp + +test-install: + ls -l $(javadir) ;: For debugging. + test -f '$(javadir)/bClass.class' + test -f '$(javadir)/aClass.class' + test -f '$(javadir)/Zardoz.class' + test -f '$(javadir)/Baz.class' + test -f '$(javadir)/Baz2.class' + test ! -r '$(javadir)/Foo.class' + test ! -r '$(javadir)/Bar.class' + if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi + +check-local: test +installcheck-local: test-install + +.PHONY: test test-install + +DISTCLEANFILES = Baz.java Foo2.java +END + +echo 'class aClass {}' > Foo.java +echo 'class Zardoz {}' > Bar.java + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure --prefix="`pwd`"/_inst +$MAKE +$MAKE test +$MAKE install +$MAKE test-install +$MAKE distcheck + +: diff --git a/tests/java-compile-run-flat.test b/tests/java-compile-run-flat.test new file mode 100755 index 000000000..b5e1c3690 --- /dev/null +++ b/tests/java-compile-run-flat.test @@ -0,0 +1,241 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test on compilation and execution of Java class files. +# Also meddle with wrapper scripts, as would be probably seen in a real +# "UNIX-style" use case. +# This test uses a "flat" setup for the source tree (i.e., everything in +# the top-level directory), and forces the use of the old, non-parallel +# testsuite driver. The sister test `java-compile-run-nested.test' do +# similar checks with a more usual, "nested" setup, and using the newer +# 'parallel-tests' driver. + +required='java javac' +am_parallel_tests=no +. ./defs || Exit 1 + +set -e + +echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in + +cat >> configure.in <<'END' +AC_SUBST([JAVA], [java]) +AC_CONFIG_SRCDIR([PkgLocation.jin]) +AC_CONFIG_FILES([PkgLocation.java:PkgLocation.jin]) +AC_OUTPUT +END + +## TOP-LEVEL SETUP AND TARGETS ## + +cat > Makefile.am <<'END' +EXTRA_DIST = # Will be updated later. + +test-built: + ls -l $(srcdir) ;: For debugging. + test $(srcdir) = . || ls -l . ;: Likewise. + test -f $(srcdir)/Main.java + test -f $(srcdir)/HelloStream.java + test -f $(srcdir)/PkgLocation.jin + test -f PkgLocation.java + test -f HelloStream.class + test -f PkgLocation.class + test -f Main.class + test -f classjava.stamp + +test-installed: + ls -l $(javadir) ;: For debugging. + test -f $(javadir)/HelloStream.class + test -f $(javadir)/PkgLocation.class + test -f $(javadir)/Main.class + if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi + +run-installed: + jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check + +check-local: test-built +installcheck-local: test-installed run-installed + +.PHONY: test-built test-installed run-installed +END + +## WRAPPER SCRIPT ## + +cat >> Makefile.am <<'END' +bin_SCRIPTS = jprog + +edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \ + -e 's|[@]javadir@|$(javadir)|g' \ + -e 's|[@]SHELL@|$(SHELL)|g' \ + -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g' + +jprog: jprog.sh + rm -f $@ $@-t + $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t + chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@ + sed 's/^/ | /' $@ ;: for debugging. + +EXTRA_DIST += jprog.sh +CLEANFILES = jprog +END + +cat > jprog.sh <<'END' +#!@SHELL@ +CLASSPATH=${jprog_classpath-'@javadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"} +export CLASSPATH +case $# in + 0) exec @JAVA@ Main;; + *) exec @JAVA@ Main "$@";; +esac +END + +## JAVA SOURCES ## + +cat >> Makefile.am <<'END' +javadir = $(pkgdatadir)/java + +dist_java_JAVA = Main.java HelloStream.java +nodist_java_JAVA = PkgLocation.java +END + +cat > PkgLocation.jin <<'END' +public class PkgLocation { + public static String prefix() { + return new String("@prefix@"); + } +} +END + +cat > Main.java <<'END' +public class Main { + public static void main(String[] args) { + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--print-prefix")) { + System.out.println(PkgLocation.prefix()); + } else if (args[i].equals("--hello-stdout")) { + HelloStream.to(System.out); + } else if (args[i].equals("--hello-stderr")) { + HelloStream.to(System.err); + } else { + System.err.println("jprog: invalid option '" + args[i] + + "'"); + System.exit(2); + } + } + System.exit(0); + } +} +END + +cat > HelloStream.java <<'END' +import java.io.PrintStream; +class HelloStream { + public static void to(PrintStream stream) { + stream.println("Hello, Stream!"); + } +} +END + +## TESTS ## + +cat >> Makefile.am <<'END' +## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available. +TESTS_ENVIRONMENT = \ + if test x"$$jprog_doing_installcheck" != x"yes"; then \ + jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \ + export jprog_classpath; \ + PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + else \ + unset jprog_classpath || :; \ + PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + fi; \ + config_time_prefix='@prefix@'; export config_time_prefix; + +TESTS = \ + simple.test \ + prefix.test \ + stdout.test \ + stderr.test \ + badarg.test + +XFAIL_TESTS = badarg.test + +EXTRA_DIST += $(TESTS) +END + +cat > simple.test <<'END' +#!/bin/sh +jprog +END + +cat > prefix.test <<'END' +#!/bin/sh +jprefix=`jprog --print-prefix` || exit 1 +echo "$0: exp prefix: $config_time_prefix" +echo "$0: got prefix: $jprefix" +test x"$jprefix" = x"$config_time_prefix" +END + +cat > stdout.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' <stdout.out # For debugging. +sed 's/^/err:/' <stdout.err >&2 # Likewise. +test -s stdout.err && rc=1 +test "`cat stdout.out`" = 'Hello, Stream!' || rc=1 +rm -f stdout.out stdout.err || rc=1 +exit $rc +END + +cat > stderr.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' <stderr.out # For debugging. +sed 's/^/err:/' <stderr.err >&2 # Likewise. +test -s stderr.out && rc=1 +test "`cat stderr.err`" = 'Hello, Stream!' || rc=1 +rm -f stderr.out stderr.err || rc=1 +exit $rc +END + +cat > badarg.test <<'END' +#!/bin/sh +jprog --bad-argument +END + +chmod a+x *.test + +## DO CHECKS ## + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# To have the parallel testsuite more verbose. +VERBOSE=yes; export VERBOSE + +./configure --prefix="`pwd`/_inst" +cat PkgLocation.java # For debugging. +$MAKE check +$MAKE install +$MAKE test-installed +$MAKE run-installed +$MAKE distcheck + +: diff --git a/tests/java-compile-run-nested.test b/tests/java-compile-run-nested.test new file mode 100755 index 000000000..9de874b85 --- /dev/null +++ b/tests/java-compile-run-nested.test @@ -0,0 +1,254 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test on compilation and execution of Java class files. +# Also meddle with wrapper scripts, as would be probably seen in a real +# "UNIX-style" use case. +# This test uses a typical "nested" source tree setup (i.e., different +# components/aspects are separated into different subdirectories), +# and uses the 'parallel-tests' testsuite driver. The sister test +# `java-compile-run-flat.test' do similar checks with a "flat" setup +# (i.e., everything in the top-level directory), and forcing the use +# of the older non-parallel 'simple-tests' driver. + +required='java javac' +am_parallel_tests=yes +. ./defs || Exit 1 + +set -e + +echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in + +cat >> configure.in <<'END' +AC_SUBST([JAVA], [java]) +AC_CONFIG_SRCDIR([jprog/PkgLocation.jin]) +AC_SUBST([jprogdatadir], ['${pkgdatadir}']) +AC_SUBST([jprogclassdir], ['${jprogdatadir}/jprog']) +AC_CONFIG_FILES([jprog/PkgLocation.java:jprog/PkgLocation.jin]) +AC_CONFIG_FILES([jprog/Makefile bin/Makefile tests/Makefile]) +AC_OUTPUT +END + +## TOP-LEVEL SETUP AND TARGETS ## + +cat > Makefile.am <<'END' +SUBDIRS = bin jprog tests + +test-built: + ls -l $(srcdir)/* ;: For debugging. + test $(srcdir) = . || ls -l * ;: Likewise. + test -f $(srcdir)/jprog/Main.java + test -f $(srcdir)/jprog/HelloStream.java + test -f $(srcdir)/jprog/PkgLocation.jin + test -f jprog/PkgLocation.java + test -f jprog/HelloStream.class + test -f jprog/Main.class + test -f jprog/PkgLocation.class + test -f jprog/classjprogclass.stamp + +test-installed: + ls -l $(jprogclassdir) ;: For debugging. + test -f $(jprogclassdir)/HelloStream.class + test -f $(jprogclassdir)/Main.class + test -f $(jprogclassdir)/PkgLocation.class + if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi + +run-installed: + jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check + +check-local: test-built +installcheck-local: test-installed run-installed + +.PHONY: test-built test-installed run-installed +END + +## WRAPPER SCRIPT ## + +mkdir bin + +cat > bin/Makefile.am <<'END' +bin_SCRIPTS = jprog + +edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \ + -e 's|[@]jprogdatadir@|$(jprogdatadir)|g' \ + -e 's|[@]SHELL@|$(SHELL)|g' \ + -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g' + +jprog: jprog.sh + rm -f $@ $@-t + $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t + chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@ + sed 's/^/ | /' $@ ;: for debugging. + +EXTRA_DIST = jprog.sh +CLEANFILES = jprog +END + +cat > bin/jprog.sh <<'END' +#!@SHELL@ +CLASSPATH=${jprog_classpath-'@jprogdatadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"} +export CLASSPATH +case $# in + 0) exec @JAVA@ jprog.Main;; + *) exec @JAVA@ jprog.Main "$@";; +esac +END + +## JAVA SOURCES ## + +mkdir jprog + +cat > jprog/Makefile.am <<'END' +dist_jprogclass_JAVA = Main.java HelloStream.java +nodist_jprogclass_JAVA = PkgLocation.java +END + +cat > jprog/PkgLocation.jin <<'END' +package jprog; +public class PkgLocation { + public static String prefix() { + return new String("@prefix@"); + } +} +END + +cat > jprog/Main.java <<'END' +package jprog; +import jprog.PkgLocation; +import jprog.HelloStream; +public class Main { + public static void main(String[] args) { + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--print-prefix")) { + System.out.println(PkgLocation.prefix()); + } else if (args[i].equals("--hello-stdout")) { + HelloStream.to(System.out); + } else if (args[i].equals("--hello-stderr")) { + HelloStream.to(System.err); + } else { + System.err.println("jprog: invalid option '" + args[i] + + "'"); + System.exit(2); + } + } + System.exit(0); + } +} +END + +cat > jprog/HelloStream.java <<'END' +package jprog; +import java.io.PrintStream; +class HelloStream { + public static void to(PrintStream stream) { + stream.println("Hello, Stream!"); + } +} +END + +## TESTS ## + +mkdir tests + +cat > tests/Makefile.am <<'END' +## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available. +TESTS_ENVIRONMENT = \ + if test x"$$jprog_doing_installcheck" != x"yes"; then \ + jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \ + export jprog_classpath; \ + PATH='$(abs_top_builddir)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + else \ + unset jprog_classpath || :; \ + PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + fi; \ + config_time_prefix='@prefix@'; export config_time_prefix; + +TESTS = \ + simple.test \ + prefix.test \ + stdout.test \ + stderr.test \ + badarg.test + +XFAIL_TESTS = badarg.test + +EXTRA_DIST = $(TESTS) +END + +cat > tests/simple.test <<'END' +#!/bin/sh +jprog +END + +cat > tests/prefix.test <<'END' +#!/bin/sh +jprefix=`jprog --print-prefix` || exit 1 +echo "$0: exp prefix: $config_time_prefix" +echo "$0: got prefix: $jprefix" +test x"$jprefix" = x"$config_time_prefix" +END + +cat > tests/stdout.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' <stdout.out # For debugging. +sed 's/^/err:/' <stdout.err >&2 # Likewise. +test -s stdout.err && rc=1 +test "`cat stdout.out`" = 'Hello, Stream!' || rc=1 +rm -f stdout.out stdout.err || rc=1 +exit $rc +END + +cat > tests/stderr.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' <stderr.out # For debugging. +sed 's/^/err:/' <stderr.err >&2 # Likewise. +test -s stderr.out && rc=1 +test "`cat stderr.err`" = 'Hello, Stream!' || rc=1 +rm -f stderr.out stderr.err || rc=1 +exit $rc +END + +cat > tests/badarg.test <<'END' +#!/bin/sh +jprog --bad-argument +END + +chmod a+x tests/*.test + +## DO CHECKS ## + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# To have the parallel testsuite more verbose. +VERBOSE=yes; export VERBOSE + +./configure --prefix="`pwd`/_inst" +cat jprog/PkgLocation.java # For debugging. +$MAKE check +$MAKE install +$MAKE test-installed +$MAKE run-installed +$MAKE distcheck + +: diff --git a/tests/java-mix.test b/tests/java-mix.test new file mode 100755 index 000000000..d6a43e79e --- /dev/null +++ b/tests/java-mix.test @@ -0,0 +1,69 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Check that the JAVA primary can be used freely in the same Makefile.am +# with proper combinations of the `dist_', `nodist_' and `nobase_' +# modifiers. Also check that `.java' files are not ditributed by default. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +# This test does not require compilation of *.java files. +JAVAC = false +javadir = $(prefix) + +java_JAVA = Class.java +dist_java_JAVA = ClassDist.java +nodist_java_JAVA = ClassNodist.java + +nobase_java_JAVA = ClassNobase.java +nobase_dist_java_JAVA = ClassNobaseDist.java +nobase_nodist_java_JAVA = ClassNobaseNodist.java + +Class.java ClassNodist.java ClassNobase.java ClassNobaseNodist.java: + @echo '$@ should not be generated!' >&2; exit 1 +END + +: > ClassDist.java +: > ClassNobaseDist.java + +$ACLOCAL +$AUTOCONF +# Automake used to display non-fatal warnings with this test, but +# they were unexpected, so we want to consider them as failures in +# this test. +$AUTOMAKE 2>stderr || { cat stderr >&2; Exit 1; } +cat stderr >&2 +test ! -s stderr + +./configure + +$MAKE distdir +ls -l $distdir # For debugging. +test ! -f $distdir/Class.java +test -f $distdir/ClassDist.java +test ! -f $distdir/ClassNobase.java +test -f $distdir/ClassNobaseDist.java +test ! -f $distdir/ClassNodist.java +test ! -f $distdir/ClassNobaseNodist.java + +: diff --git a/tests/java-no-duplicate.test b/tests/java-no-duplicate.test new file mode 100755 index 000000000..ec42a3b09 --- /dev/null +++ b/tests/java-no-duplicate.test @@ -0,0 +1,47 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test that some Java-related variables and rules are not repeatedly +# defined. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +javadir = $(datadir)/java +java_JAVA = a.java +dist_java_JAVA = b.java +nodist_java_JAVA = c.java +nobase_java_JAVA = d.java +nobase_dist_java_JAVA = e.java +nobase_nodist_java_JAVA = f.java +END + +$ACLOCAL +$AUTOMAKE + +$EGREP -i '\.stamp|\.class|java|classpath' Makefile.in # For debugging. + +for var in JAVAC JAVAROOT CLASSPATH_ENV am__java_sources; do + grep "^$var =" Makefile.in + test `grep -c "^[$sp$tab]*$var[$sp$tab]*=" Makefile.in` = 1 +done + +grep '^classjava\.stamp:' Makefile.in +test `grep -c "class.*java.*\.stamp.*:" Makefile.in` = 1 + +: diff --git a/tests/java-nobase.test b/tests/java-nobase.test new file mode 100755 index 000000000..7b55290f4 --- /dev/null +++ b/tests/java-nobase.test @@ -0,0 +1,67 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test support of `nobase_' with the `JAVA' primary. + +required=javac +. ./defs || Exit 1 + +set -e + +cat >>configure.in <<'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +javadir = $(datadir)/java +nobase_java_JAVA = sub/subsub/Foo.java +nobase_dist_java_JAVA = sub/Bar.java +nobase_nodist_java_JAVA = sub2/Baz.java + +# Java files are not distributed by default. +EXTRA_DIST = sub/subsub/Foo.java + +sub2/Baz.java: + rm -f $@ $@-t + test -d sub2 || mkdir sub2 + echo 'class Baz {}' > $@-t + chmod a-w $@-t && mv -f $@-t $@ + +.PHONY: test-install +test-install: + find $(prefix) ;: For debugging. + test -f $(javadir)/sub/subsub/Foo.class + test -f $(javadir)/sub/Bar.class + test -f $(javadir)/sub2/Baz.class +installcheck-local: test-install +DISTCLEANFILES = sub2/Baz.java +END + +mkdir sub sub/subsub +echo 'class Foo {}' > sub/subsub/Foo.java +echo 'class Bar {}' > sub/Bar.java + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure --prefix="`pwd`"/_inst +$MAKE check +$MAKE install +$MAKE test-install +$MAKE distcheck + +: diff --git a/tests/java-noinst.test b/tests/java-noinst.test index 5fe66d81a..eb90aa973 100755 --- a/tests/java-noinst.test +++ b/tests/java-noinst.test @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Make sure that noinst_JAVA causes generated *.class files not to be -# installed. +# Make sure that noinst_JAVA causes generated *.class files not to +# be installed. required=javac . ./defs || Exit 1 @@ -24,28 +24,32 @@ cat >> configure.in << 'END' AC_OUTPUT END -cat > Foo.java <<'END' -class Foo { } +cat > Makefile.am <<'END' +noinst_JAVA = 1.java +dist_noinst_JAVA = 2.java +nodist_noinst_JAVA = 3.java +nobase_noinst_JAVA = 4.java +nobase_dist_noinst_JAVA = 5.java +nobase_nodist_noinst_JAVA = 6.java END +for i in 1 2 3 4 5 6; do + echo "class Class$i {}" > $i.java +done + $ACLOCAL +$AUTOMAKE $AUTOCONF -: > Makefile.in # Will be updated later. - ./configure --prefix="`pwd`/_inst" -# We need this hacky loop because multiple uses of the JAVA primary -# in the same Makefile.am are not allowed. - -for prefix in '' nodist_ dist_; do - echo "${prefix}noinst_JAVA = Foo.java" > Makefile.am - $AUTOMAKE - ./config.status Makefile - $MAKE - test -f Foo.class - $MAKE install - test ! -d _inst +$MAKE +ls -l +for i in 1 2 3 4 5 6; do + test -f Class$i.class done +$MAKE install +test -d _inst && { ls -l _inst; Exit 1; } + : diff --git a/tests/java-rebuild.test b/tests/java-rebuild.test new file mode 100755 index 000000000..75be5f733 --- /dev/null +++ b/tests/java-rebuild.test @@ -0,0 +1,126 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test rebuild rules for Java class files. + +required='javac' +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_OUTPUT +END + +cat > Makefile.am <<'END' +AM_JAVACFLAGS = -verbose +foodir = $(datadir)/java +foo_JAVA = a.java +dist_foo_JAVA = d.java +nodist_foo_JAVA = n.java +nobase_foo_JAVA = Nobase.java +nobase_dist_foo_JAVA = NobaseDist.java +nobase_nodist_foo_JAVA = NobaseNoDist.java +END + +echo 'class _x {}' > a.java +echo 'class x_ {}' > d.java +echo 'class a {} class d {}' > n.java +echo 'class Nobase_Foo {} class Nobase_Bar {}' > Nobase.java +echo 'class NobaseDist {}' > NobaseDist.java +echo 'class NobaseNoDist {}' > NobaseNoDist.java + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +all_classes='_x x_ a d Nobase_Foo Nobase_Bar NobaseDist NobaseNoDist' + +for vpath in : false; do + + if $vpath; then + srcdir=.. + mkdir build + cd build + else + srcdir=. + fi + + $srcdir/configure + $MAKE + ls -l # For debugging. + + # Sanity check. + test -f classfoo.stamp + for cls in $all_classes; do + test -f $cls.class + done + + # When the stampfile is removed, all the *.class files should + # be considered out-of-date. + echo timestamp > older + $sleep + rm -f classfoo.stamp + $MAKE + for cls in $all_classes; do + is_newest $cls.class older + done + + # When only a java file is modified, only the *.class files derived from + # it should be updated. + # The strings we loop on here have the following format: + # ``JAVA-FILES-TO-BE-TOUCHED -- CLASSES-THAT-SHOULD-BE-UPDATED'' + for args in \ + 'a -- _x' \ + 'd -- x_' \ + 'n -- a d' \ + 'a d Nobase -- _x x_ Nobase_Foo Nobase_Bar' \ + 'n NobaseDist -- a d NobaseDist' \ + 'd NobaseNoDist -- x_ NobaseNoDist' \ + "a d n Nobase NobaseDist NobaseNoDist -- $all_classes" \ + ; do + set $args + touched_javas= + while test $# -gt 0; do + if test x"$1" = x"--"; then + shift + break + else + touched_javas="$touched_javas $1" + shift + fi + done + updated_classes=$* + echo timestamp > older + $sleep + for j in $touched_javas; do + touch $srcdir/$j.java + done + $MAKE + is_newest classfoo.stamp older + for cls in $all_classes; do + case " $updated_classes " in + *" $cls "*) is_newest $cls.class older;; + *) is_newest older $cls.class;; + esac + done + done # $args ... + + cd $srcdir + +done # $vpath ... + +: diff --git a/tests/java-sources.test b/tests/java-sources.test new file mode 100755 index 000000000..770eb2d16 --- /dev/null +++ b/tests/java-sources.test @@ -0,0 +1,67 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test definition of automake-generated private Makefile variable +# `$(am__java_sources)'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +foodir = $(prefix) + +foo_JAVA = a.java +dist_foo_JAVA = b.java +nodist_foo_JAVA = c.java +nobase_foo_JAVA = d.java +nobase_dist_foo_JAVA = e.java +nobase_nodist_foo_JAVA = f.java + +.PHONY: debug +debug: + @echo 'am__java_sources: "$(am__java_sources)"' +got: + @lst='$(am__java_sources)'; \ + for f in $$lst; do echo $$f; done | sort > $@ +END + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +cat > exp << 'END' +a.java +b.java +c.java +d.java +e.java +f.java +END + +./configure +$MAKE debug +$MAKE got + +cat got +cat exp +diff exp got + +: diff --git a/tests/java-uninstall.test b/tests/java-uninstall.test new file mode 100755 index 000000000..35d1e4a04 --- /dev/null +++ b/tests/java-uninstall.test @@ -0,0 +1,101 @@ +#! /bin/sh +# Copyright (C) 1998, 2001, 2002, 2004, 2007 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/>. + +# Check uninstallation of Java class files. + +required=javac +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +javadir = $(prefix)/java +java_JAVA = Foo.java +nobase_java_JAVA = Foo2.java +nobase_dist_java_JAVA = Bar.java +nodist_java_JAVA = Baz.java + +# Java files are not distributed by default, so we distribute +# one "by hand" ... +EXTRA_DIST = Foo.java +# ... and make the other one generated. +Foo2.java: + rm -f $@ $@-t + echo 'class bClass {}' > $@-t + chmod a-w $@-t && mv -f $@-t $@ + +# Explicitly declared as `nodist_', so generate it. +Baz.java: + rm -f $@ $@-t + echo 'class Baz {}' > $@-t + echo 'class Baz2 {}' >> $@-t + chmod a-w $@-t && mv -f $@-t $@ + +DISTCLEANFILES = Baz.java Foo2.java +END + +echo 'class aClass {}' > Foo.java +echo 'class Zardoz {}' > Bar.java + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure --prefix="`pwd`"/_inst +javadir=_inst/java + +check_uninstallation() +{ + test ! -r $javadir/aClass.class + test ! -r $javadir/bClass.class + test ! -r $javadir/Zardoz.class + test ! -r $javadir/Baz.class + test ! -r $javadir/Baz2.class + test -f $javadir/Foo.class + test -f $javadir/Bar.class + test -f $javadir/xClass.class + test -f $javadir/aclass.class +} + +$MAKE +ls -l +$MAKE install +: > $javadir/Foo.class +: > $javadir/Bar.class +: > $javadir/xClass.class +: > $javadir/aclass.class +ls -l $javadir +$MAKE uninstall +ls -l $javadir +check_uninstallation + +# FIXME: "make uninstall" should continue to work also after "make clean", +# but currently this doesn't happen. See automake bug#8540. +$MAKE install +ls -l $javadir +$MAKE clean +ls -l +$MAKE uninstall +ls -l $javadir +#check_uninstallation + +$MAKE distcheck + +: diff --git a/tests/java.test b/tests/java.test index 671d2fda2..fdf209297 100755 --- a/tests/java.test +++ b/tests/java.test @@ -24,7 +24,6 @@ cat >>configure.in <<'EOF' AC_OUTPUT EOF - cat > Makefile.am << 'END' javadir = $(datadir)/java dist_java_JAVA = a.java b.java @@ -33,7 +32,10 @@ END $ACLOCAL $AUTOCONF $AUTOMAKE -grep '^all[-a-z]*:.*classdist_java\.stamp' Makefile.in + +$EGREP '\.stamp|class' Makefile.in # For debugging. +grep '^all[-a-z]*:.*classjava\.stamp' Makefile.in +test `grep -c '^all[-a-z]*:.*classjava\.stamp' Makefile.in` -eq 1 cat >a.java <<EOF class a diff --git a/tests/javaflags.test b/tests/javaflags.test new file mode 100755 index 000000000..75643222f --- /dev/null +++ b/tests/javaflags.test @@ -0,0 +1,62 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Check support for $(JAVACFLAGS) and $(AM_JAVACFLAGS). + +. ./defs || Exit 1 + +set -e + +cat > fake-javac <<'END' +#!/bin/sh +echo "$*" > javaflags.list +END +chmod a+x fake-javac + +# Remove JAVAC from the environment, so that it won't interfere +# with `make -e' below. +unset JAVAC || : + +cat >> configure.in <<'END' +AC_PROG_CC +# Simulate presence of the java compiler using our fake-javac script. +AC_SUBST([JAVAC], ['$(abs_top_srcdir)'/fake-javac]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +foodir = $(prefix) +foo_JAVA = bar.java +AM_JAVACFLAGS = __am_flags__ +END + +$ACLOCAL +$AUTOMAKE + +grep '\$(JAVACFLAGS).*\$(AM_JAVACFLAGS)' Makefile.in && Exit 1 + +: > bar.java + +$AUTOCONF +./configure +env JAVACFLAGS=__user_flags__ $MAKE -e + +ls -l + +cat javaflags.list +grep '__am_flags__.*__user_flags__' javaflags.list + +: diff --git a/tests/javaprim.test b/tests/javaprim.test index f0b8a1a02..f80cec909 100755 --- a/tests/javaprim.test +++ b/tests/javaprim.test @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Test to make sure JAVA variable can be defined. +# Test to make sure JAVA variable can be defined by AC_SUBST. . ./defs || Exit 1 @@ -31,4 +31,7 @@ END $ACLOCAL $AUTOMAKE +grep -i java Makefile.in # For debugging. +grep '^JAVA = *@JAVA@ *$' Makefile.in + : diff --git a/tests/javasubst.test b/tests/javasubst.test index 6b867d986..7d6dd9c88 100755 --- a/tests/javasubst.test +++ b/tests/javasubst.test @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Test to make sure redefining JAVAC works. +# Test to make sure redefining JAVAC with AC_SUBST works. . ./defs || Exit 1 @@ -31,6 +31,7 @@ END $ACLOCAL $AUTOMAKE -grep 'JAVAC.*@JAVAC@' Makefile.in +grep -i java Makefile.in # For debugging. +grep '^JAVAC = *@JAVAC@ *$' Makefile.in : diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index 723cb6a3f..249981859 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -446,12 +446,23 @@ interp2.test \ java.test \ java2.test \ java3.test \ +javaflags.test \ java-check.test \ +java-clean.test \ +java-compile-install.test \ +java-compile-run-flat.test \ +java-compile-run-nested.test \ java-empty-classpath.test \ javaprim.test \ javasubst.test \ java-extra.test \ +java-mix.test \ +java-no-duplicate.test \ +java-nobase.test \ java-noinst.test \ +java-rebuild.test \ +java-sources.test \ +java-uninstall.test \ ldadd.test \ ldflags.test \ lex.test \ @@ -579,6 +590,7 @@ no-outdir-option.test \ nobase.test \ nobase-libtool.test \ nobase-python.test \ +nobase-nodist.test \ nodef.test \ nodef2.test \ nodep.test \ @@ -743,6 +755,14 @@ primary-prefix-couples-force-valid.test \ primary-prefix-couples-documented-valid.test \ proginst.test \ programs-primary-rewritten.test \ +py-compile-basedir.test \ +py-compile-basic.test \ +py-compile-basic2.test \ +py-compile-destdir.test \ +py-compile-env.test \ +py-compile-option-terminate.test \ +py-compile-usage.test \ +python-dist.test \ python.test \ python2.test \ python3.test \ diff --git a/tests/nobase-nodist.test b/tests/nobase-nodist.test new file mode 100644 index 000000000..90823e2a3 --- /dev/null +++ b/tests/nobase-nodist.test @@ -0,0 +1,62 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Interaction of `nobase_' and `nodist_' prefixes. + +. ./defs || Exit 1 + +set -e + +# Simulate no emacs and no python (it shouldn't be needed in this test). +EMACS="no" PYTHON=":"; export EMCAS PYTHON + +cat >> configure.in << 'END' +AM_PATH_LISPDIR +AM_PATH_PYTHON([], [], [:]) +# Simulate no javac (it shouldn't be needed in this test). +AC_SUBST([JAVAC], [false]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +nobase_nodist_noinst_PYTHON = baz1.py sub/baz2.py +# Lisp and Java sources are not distributed by default, so try both +# with and without the `nodist_' prefix, for more coverage. +nobase_noinst_LISP = foo1.el sub/foo2.el +nobase_nodist_noinst_LISP = foo3.el sub/foo4.el +nobase_noinst_JAVA = bar1.java sub/bar2.java +nobase_nodist_noinst_JAVA = bar3.java sub/bar4.java +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a +./configure +$MAKE distdir + +ls -l $distdir $distdir/* # For debugging. +test ! -f $distdir/foo1.el +test ! -f $distdir/sub/foo2.el +test ! -f $distdir/foo3.el +test ! -f $distdir/sub/foo4.el +test ! -f $distdir/bar1.java +test ! -f $distdir/sub/bar2.java +test ! -f $distdir/bar3.java +test ! -f $distdir/sub/bar4.java +test ! -f $distdir/baz1.py +test ! -f $distdir/sub/baz2.py + +: diff --git a/tests/py-compile-basedir.test b/tests/py-compile-basedir.test new file mode 100755 index 000000000..a277639cb --- /dev/null +++ b/tests/py-compile-basedir.test @@ -0,0 +1,51 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test the `--basedir' option of the `py-compile' script, + +required=python +. ./defs || Exit 1 + +set -e + +# We'll need to create files in `..', so we need one more subdirectory +# level in order not to clutter up the top-level tests directory. +mkdir sandbox +cd sandbox + +cp "$testsrcdir/../lib/py-compile" . + +f=__init__ +for d in foo foo/bar "`pwd`/foo" . .. ../foo ''; do + if test -z "$d"; then + d2=. + else + d2=$d + fi + ../install-sh -d "$d2" "$d2/sub" || Exit 99 + : > "$d2/$f.py" + : > "$d2/sub/$f.py" + ./py-compile --basedir "$d" "$f.py" "sub/$f.py" + ls -l "$d2" "$d2/sub" # For debugging. + test -f "$d2/$f.pyc" + test -f "$d2/$f.pyo" + test -f "$d2/sub/$f.pyc" + test -f "$d2/sub/$f.pyo" + rm -f "$d2/$f.pyc" "$d2/$f.pyo" "$d2/sub/$f.pyc" "$d2/sub/$f.pyo" + find . | grep '\.py[co]$' && Exit 1 +done + +: diff --git a/tests/py-compile-basic.test b/tests/py-compile-basic.test new file mode 100755 index 000000000..a7a3f899c --- /dev/null +++ b/tests/py-compile-basic.test @@ -0,0 +1,64 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test more basic functionalities of the `py-compile' script, +# with "believable" python sources. See also related test +# `py-compile-basic2.test'. + +required=python +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +cat > foo.py <<'END' +# Try out some non-trivial syntax in here. + +'''Module docstring''' + +def foo (*args, **kwargs): + """Function docstring + with embedded newline""" + return 1 + +class Foo: + r"""Class docstring""" + def __init__(self): + r'''Method docstring + with + embedded + newlines''' + pass + +bar = baz = (1, (2,), [3, 4]); zardoz = 0; +END + +cat > bar.py <<'END' +# Import of non-existent modules, or assertion of false conditions, +# shouldn't cause problems, as it should be enough for the code to +# be syntactically correct. +import Automake.No.Such.Module +assert False +END + +./py-compile foo.py bar.py +test -f foo.pyc +test -f foo.pyo +test -f bar.pyc +test -f bar.pyo + +: diff --git a/tests/py-compile-basic2.test b/tests/py-compile-basic2.test new file mode 100755 index 000000000..0da0d4231 --- /dev/null +++ b/tests/py-compile-basic2.test @@ -0,0 +1,71 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test more basic functionalities of the `py-compile' script, with +# dummy python sources, but more complex directory layouts. See also +# related test `py-compile-basic.test'. + +required=python +. ./defs || Exit 1 + +set -e + +ocwd=`pwd` || Exit 99 + +pyfiles=" + foo.py + ./foo1.py + ../foo2.py + ../dir/foo3.py + $ocwd/foo4.py + sub/bar.py + sub/subsub/barbar.py + __init__.py + sub/__init__.py + 1.py + .././_.py +" + +lst=' + dir/foo + dir/foo1 + foo2 + dir/foo3 + foo4 + dir/sub/bar + dir/sub/subsub/barbar + dir/__init__ + dir/sub/__init__ + dir/1 + _ +' + +mkdir dir +cd dir +cp "$testsrcdir/../lib/py-compile" . +mkdir sub sub/subsub +touch $pyfiles +./py-compile $pyfiles +cd "$ocwd" + +for x in $lst; do echo $x.pyc; echo $x.pyo; done | sort > exp +find . -name '*.py[co]' | sed 's|^\./||' | sort > got + +cat exp +cat got +diff exp got + +: diff --git a/tests/py-compile-destdir.test b/tests/py-compile-destdir.test new file mode 100755 index 000000000..3d122e64b --- /dev/null +++ b/tests/py-compile-destdir.test @@ -0,0 +1,44 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test the `--destdir' option of the `py-compile' script, + +required=python +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +# Should not give false positives when grepping for it, so use +# an "uncommon" string (with ugly CamelCase). +destdir=TheDestDir + +mkdir sub $destdir $destdir/sub +echo 'def foo (): return "foo"' > $destdir/foo.py +echo 'def bar (): return "bar"' > $destdir/sub/bar.py + +./py-compile --destdir $destdir foo.py sub/bar.py +ls -l $destdir $destdir/sub # For debugging. +ls . sub | grep '\.py[co]$' && Exit 1 +test -f $destdir/foo.pyc +test -f $destdir/foo.pyo +test -f $destdir/sub/bar.pyc +test -f $destdir/sub/bar.pyo +strings $destdir/*.py[co] $destdir/sub/*.py[co] || : # For debugging. +$FGREP $destdir $destdir/*.py[co] $destdir/sub/*.py[co] && Exit 1 + +: diff --git a/tests/py-compile-env.test b/tests/py-compile-env.test new file mode 100755 index 000000000..a72d173c8 --- /dev/null +++ b/tests/py-compile-env.test @@ -0,0 +1,60 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Make sure `py-compile' honours the PYTHON environment variable. + +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +cat > my-py <<'END' +#!/bin/sh +: > my-py.run +END +chmod a+x my-py + +mkdir sub1 +cd sub1 + +PYTHON=: ../py-compile foo.py +ls | grep . && Exit 1 + +PYTHON=false ../py-compile foo.py && Exit 1 +ls | grep . && Exit 1 + +PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py +PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py | grep 'GrEpMe AndMeToo' +ls | grep . && Exit 1 + +cd .. +mkdir sub2 +cd sub2 + +PYTHON=../my-py ../py-compile foo.py +test -f my-py.run +ls | grep -v '^my-py\.run$' | grep . && Exit 1 + +cd .. +mkdir sub3 +cd sub3 +PATH=..$PATH_SEPARATOR$PATH; export PATH +PYTHON=my-py py-compile foo.py +test -f my-py.run +ls | grep -v '^my-py\.run$' | grep . && Exit 1 + +: diff --git a/tests/py-compile-option-terminate.test b/tests/py-compile-option-terminate.test new file mode 100755 index 000000000..69f9bb5f1 --- /dev/null +++ b/tests/py-compile-option-terminate.test @@ -0,0 +1,44 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Check that a non-option argument and the `--' special argument +# explicitly terminate the option list for `py-compile'. + +required=python +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +: > ./-o.py +: > ./--foo.py +./py-compile -- -o.py --foo.py +test -f ./-o.pyc +test -f ./-o.pyo +test -f ./--foo.pyc +test -f ./--foo.pyo +rm -f ./-*.py[co] +: > x.py +./py-compile x.py -o.py --foo.py +test -f ./x.pyc +test -f ./x.pyo +test -f ./-o.pyc +test -f ./-o.pyo +test -f ./--foo.pyc +test -f ./--foo.pyo + +: diff --git a/tests/py-compile-usage.test b/tests/py-compile-usage.test new file mode 100755 index 000000000..7e8c78605 --- /dev/null +++ b/tests/py-compile-usage.test @@ -0,0 +1,75 @@ +#! /bin/sh +# Copyright (C) 2011 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/>. + +# Test `py-compile --help', `py-compile --version', and that `py-compile' +# correctly complains on wrong usage. + +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +# --help + +./py-compile --help >stdout 2>stderr \ + || { cat stdout; cat stderr >&2; Exit 1; } +cat stdout +test -s stderr && { cat stderr >&2; Exit 1; } +grep '^Usage: py-compile .' stdout +$FGREP ' [--basedir DIR]' stdout +$FGREP ' [--destdir DIR]' stdout + +# --version + +./py-compile --version >stdout 2>stderr \ + || { cat stdout; cat stderr >&2; Exit 1; } +cat stdout +test -s stderr && { cat stderr >&2; Exit 1; } +year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-) +month='(0[0-9]|1[012])' +day='([012][0-9]|3[01])' +hour='([01][0-9]|2[0123])' +LC_ALL=C $EGREP "^py-compile $year-$month-$day\.$hour" stdout +test `wc -l <stdout` -eq 1 + +# Unknown option. +for opt in -b -d --foo; do + ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; } + cat stderr >&2 + grep "^py-compile: unrecognized option ['\`]$opt'" stderr + grep "^Try [\`']py-compile --help' for more information" stderr +done + +# Missing option argument. + +for opt in --basedir --destdir; do + ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; } + cat stderr >&2 + grep "^py-compile: option ['\`]$opt' requires an argument" stderr + grep "^Try [\`']py-compile --help' for more information" stderr +done + +# Missing files. + +for args in '' '--basedir dir' '--destdir dir'; do + ./py-compile $args 2>stderr && { cat stderr >&2; Exit 1; } + cat stderr >&2 + grep '^py-compile: no files given' stderr + grep "^Try [\`']py-compile --help' for more information" stderr +done + +: |