summaryrefslogtreecommitdiff
path: root/t/ax/is_newest
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-06-22 16:18:28 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-06-22 16:38:09 +0200
commitdc18830f56e88efa2cd92e663d30b9d4f0f27f1b (patch)
tree87db4288be9a979284fcf329b63c82110c17fc74 /t/ax/is_newest
parent9c90cf76767e4629349e3cce61dc587185f4eda1 (diff)
downloadautomake-dc18830f56e88efa2cd92e663d30b9d4f0f27f1b.tar.gz
tests: implement is_newest as an auxiliary script, not shell function
This will allow to also use it in the makefile recipes used in our test cases. * t/ax/test-init.sh (is_newest): Remove. * t/ax/is_newest: New script. * Makefile.am (EXTRA_DIST): Add it. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/ax/is_newest')
-rwxr-xr-xt/ax/is_newest40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/ax/is_newest b/t/ax/is_newest
new file mode 100755
index 000000000..f52a1a8e3
--- /dev/null
+++ b/t/ax/is_newest
@@ -0,0 +1,40 @@
+#! /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/>.
+
+# Usage: is_newest FILE FILES
+# Fail if any file in FILES is newer than FILE, and print the list of
+# such files on the standard error.
+# Resolve ties in favor of FILE.
+
+set -u
+
+me=is_newest
+
+if test $# -lt 2; then
+ echo "$me: too few arguments" >&2
+ exit 2
+fi
+
+file=$1; shift
+newer_files=$(find "$@" -prune -newer "$file") || exit $?
+
+if test -n "$newer_files"; then
+ echo "$me: these files are newer than '$file':" >&2
+ for f in $newer_files; do echo "* $f" >&2; done
+ exit 1
+fi
+
+exit 0