[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-vc-dwim] [PATCH] tests: update to use gnulib's init.sh
From: |
Jim Meyering |
Subject: |
[Bug-vc-dwim] [PATCH] tests: update to use gnulib's init.sh |
Date: |
Thu, 05 May 2011 13:51:04 +0200 |
FYI, I've updated all tests to use gnulib's init.sh.
vc-dwim was using a precursor of init.sh.
Here's the change to update it to use the more modern framework.
This is large, but most of the work was manual/mechanical.
>From 52e0923460b5ebf612b8208fe59487b55b9d12a5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 4 May 2011 17:52:40 +0200
Subject: [PATCH] tests: update to use gnulib's init.sh
* tests/init.sh: New file, from gnulib.
* tests/init.cfg: New file. Most content from trap-setup.
* tests/trap-setup: Remove file. Subsumed by init.sh and init.cfg.
* tests/Makefile.am (EXTRA_DIST): Add init.cfg, init.sh.
Remove trap-setup
* tests/no-vc: Use init.sh, not trap-setup. Adjust.
* tests/cl-but-no-diff: Likewise.
* tests/cl-other-user: Likewise.
* tests/no-star: Likewise.
* tests/leading-comment: Likewise.
* tests/subdir-middle: Likewise.
* tests/subdir: Likewise.
* tests/two-line-attr: Likewise.
* tests/git-log-summary: Likewise.
* tests/git-mv: Likewise.
* tests/two-vc: Likewise.
* tests/add-empty: Likewise.
* tests/scalar: Likewise.
* tests/author: Likewise.
* tests/dirty-workdir: Likewise.
* tests/subdir-cvs: Likewise.
* tests/symlinked-changelog: Likewise.
* tests/multiple-chlogs: Likewise.
* tests/t-vc-chlog: Likewise.
---
tests/Makefile.am | 3 +-
tests/add-empty | 25 +--
tests/author | 33 +--
tests/cl-but-no-diff | 25 +--
tests/cl-other-user | 25 +--
tests/dirty-workdir | 13 +-
tests/git-log-summary | 29 +--
tests/git-mv | 27 +--
tests/{trap-setup => init.cfg} | 50 ++---
tests/init.sh | 474 ++++++++++++++++++++++++++++++++++++++++
tests/leading-comment | 25 +--
tests/multiple-chlogs | 14 +-
tests/no-star | 27 +--
tests/no-vc | 19 +--
tests/scalar | 33 +--
tests/subdir | 27 +--
tests/subdir-cvs | 34 +--
tests/subdir-middle | 31 +--
tests/symlinked-changelog | 29 +--
tests/t-vc-chlog | 13 +-
tests/two-line-attr | 25 +--
tests/two-vc | 33 +--
22 files changed, 621 insertions(+), 393 deletions(-)
rename tests/{trap-setup => init.cfg} (54%)
create mode 100644 tests/init.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1ceee3c..fa95a29 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,8 @@
# This file may be modified and/or distributed without restriction.
EXTRA_DIST = $(TESTS) \
- trap-setup
+ init.cfg \
+ init.sh
TESTS = \
git-log-summary \
diff --git a/tests/add-empty b/tests/add-empty
index b44de15..c755877 100755
--- a/tests/add-empty
+++ b/tests/add-empty
@@ -1,20 +1,12 @@
#!/bin/sh
# Handle git-diff headers upon adding an empty file.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp && cd $tmp \
- || framework_failure=1
-
-cat <<EOF > ChangeLog || framework_failure=1
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
EOF
git init > /dev/null \
@@ -23,15 +15,15 @@ git init > /dev/null \
&& git commit -m m . > /dev/null \
&& git mv x y \
&& : > y \
- || framework_failure=1
+ || framework_failure_
-cat <<EOF >> ChangeLog || framework_failure=1
+cat <<EOF >> ChangeLog || framework_failure_
* x: Rename to...
* y: ...this.
EOF
-cat <<\EOF > exp || framework_failure=1
+cat <<\EOF > exp || framework_failure_
* x: Rename to...
* y: ...this.
diff --git a/x b/x
@@ -46,11 +38,6 @@ new file mode 100644
index 0000000..e69de29
EOF
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
set -e
vc-dwim ChangeLog > out
diff --git a/tests/author b/tests/author
index 9a9bf0d..7ad8357 100755
--- a/tests/author
+++ b/tests/author
@@ -1,39 +1,26 @@
#!/bin/sh
# Exercise the --author='user name <address@hidden>' option.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp && cd $tmp \
- || framework_failure=1
-
-cat <<EOF > ChangeLog || framework_failure=1
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
EOF
git init > /dev/null 2>&1 \
&& git add . \
&& git commit -m m . > /dev/null 2>&1 \
- || framework_failure=1
+ || framework_failure_
-touch x || framework_failure=1
-git add x || framework_failure=1
-cat <<EOF >> ChangeLog || framework_failure=1
+touch x || framework_failure_
+git add x || framework_failure_
+cat <<EOF >> ChangeLog || framework_failure_
* x: whatever...
EOF
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
set -e
fail=0
@@ -45,7 +32,7 @@ grep "^Author: $name_and_addr" out > /dev/null
##################################################
# Now ensure that with no --author=... option, the
# name in ChangeLog entry is used as the author.
-cat <<EOF > t || framework_failure=1
+cat <<EOF > t || framework_failure_
2006-09-05 X Y <address@hidden>
* x: Done.
@@ -62,7 +49,7 @@ grep '^Author: X Y <address@hidden>' out > /dev/null
##################################################
# Now ensure that when --author=... and ChangeLog
# disagree, vc-dwim objects.
-cat <<EOF > t || framework_failure=1
+cat <<EOF > t || framework_failure_
2006-09-06 X Y <address@hidden>
* x: Done, again.
@@ -78,7 +65,7 @@ vc-dwim --author='address@hidden' --commit 2> /dev/null || :
##################################################
# Finally, ensure that when --author=S matches the name/email
# in ChangeLog it works.
-cat <<EOF > t || framework_failure=1
+cat <<EOF > t || framework_failure_
2006-09-07 X Y <address@hidden>
* x: Last.
diff --git a/tests/cl-but-no-diff b/tests/cl-but-no-diff
index 7d3b64c..7112506 100755
--- a/tests/cl-but-no-diff
+++ b/tests/cl-but-no-diff
@@ -2,33 +2,20 @@
# Check for when there's a one-line ChangeLog entry but no diffs
# to the named file.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-cat <<EOF > ChangeLog || framework_failure=1
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
* foo: bar.
EOF
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
set -e
diff --git a/tests/cl-other-user b/tests/cl-other-user
index eda8ae4..61ecb0d 100755
--- a/tests/cl-other-user
+++ b/tests/cl-other-user
@@ -1,28 +1,15 @@
#!/bin/sh
# Demonstrate that the code accepts another flavor of ChangeLog entry.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f ChangeLog || framework_failure=1
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch f ChangeLog || framework_failure_
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
fail=0
diff --git a/tests/dirty-workdir b/tests/dirty-workdir
index 41078fe..00aa325 100644
--- a/tests/dirty-workdir
+++ b/tests/dirty-workdir
@@ -1,19 +1,10 @@
#! /bin/sh
# Test vc-chlog.
-if test "$VERBOSE" = yes; then
- set -x
- vc-chlog --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-chlog
require_git_
-mkdir -p $tmp && cd $tmp || {
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-}
-
# Let's see whether this system knows unidiff format.
# We assume that if diff doesn't, then patch also won't.
# As long as vc-chlog only works with unidiff, SKIP the test.
diff --git a/tests/git-log-summary b/tests/git-log-summary
index b1f858a..bf55f29 100755
--- a/tests/git-log-summary
+++ b/tests/git-log-summary
@@ -1,45 +1,32 @@
#!/bin/sh
# ensure that vc-dwim inserts a blank line when necessary
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp && cd $tmp \
- || framework_failure=1
-
-cat <<EOF > ChangeLog || framework_failure=1
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
EOF
git init > /dev/null 2>&1 \
&& git add . \
&& git commit -m m . > /dev/null 2>&1 \
- || framework_failure=1
+ || framework_failure_
-touch x || framework_failure=1
-git add x || framework_failure=1
-cat <<EOF >> ChangeLog || framework_failure=1
+touch x || framework_failure_
+git add x || framework_failure_
+cat <<EOF >> ChangeLog || framework_failure_
Summary
* x: body
EOF
-cat <<EOF >> exp || framework_failure=1
+cat <<EOF >> exp || framework_failure_
Summary
* x: body
EOF
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
set -e
fail=0
diff --git a/tests/git-mv b/tests/git-mv
index 5ba29c0..3fba537 100755
--- a/tests/git-mv
+++ b/tests/git-mv
@@ -3,20 +3,12 @@
# This also exercises the other fix: handle a diff header line
# with only one comma, e.g., "@@ -1 +1,4 @@".
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp && cd $tmp \
- || framework_failure=1
-
-cat <<EOF > ChangeLog || framework_failure=1
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
EOF
git init > /dev/null \
@@ -24,15 +16,15 @@ git init > /dev/null \
&& git add . \
&& git commit -m m . > /dev/null \
&& git mv x y \
- || framework_failure=1
+ || framework_failure_
-cat <<EOF >> ChangeLog || framework_failure=1
+cat <<EOF >> ChangeLog || framework_failure_
* x: Rename to...
* y: ...this.
EOF
-cat <<\EOF > exp || framework_failure=1
+cat <<\EOF > exp || framework_failure_
* x: Rename to...
* y: ...this.
diff --git a/x b/y
@@ -42,7 +34,7 @@ rename to y
EOF
# You get different output for a renaming, with older versions.
-cat <<\EOF > exp-old || framework_failure=1
+cat <<\EOF > exp-old || framework_failure_
* x: Rename to...
* y: ...this.
diff --git a/x b/x
@@ -53,11 +45,6 @@ new file mode 100644
index 0000000..e69de29
EOF
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
set -e
vc-dwim ChangeLog > out
diff --git a/tests/trap-setup b/tests/init.cfg
similarity index 54%
rename from tests/trap-setup
rename to tests/init.cfg
index 2b3b42b..c1cb6a2 100644
--- a/tests/trap-setup
+++ b/tests/init.cfg
@@ -1,23 +1,8 @@
-# -*- sh -*- common set-up code for each test
+# This file is sourced by init.sh, *before* its initialization.
-# We use a trap below for cleanup. This requires us to go through
-# hoops to get the right exit status transported through the signal.
-# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
-# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
-# sh inside this function.
-Exit()
-{
- set +e
- (exit $1)
- exit $1
-}
-
-skip_test_()
-{
- echo "$0: skipping test: $@" | head -1 1>&9
- echo "$0: skipping test: $@" 1>&2
- Exit 77
-}
+# This goes hand in hand with the "exec 9>&2;" in tests/Makefile.am's
+# TESTS_ENVIRONMENT definition.
+stderr_fileno_=9
require_bzr_()
{
@@ -35,7 +20,7 @@ require_bzr_()
fi
test $have_bzr = 0 &&
- skip_test_ "this test requires bzr"
+ skip_ "this test requires bzr"
}
require_git_()
@@ -53,7 +38,7 @@ require_git_()
fi
test $have_git = 0 &&
- skip_test_ "this test requires git"
+ skip_ "this test requires git"
}
require_cvs_()
@@ -65,7 +50,7 @@ require_cvs_()
fi
test $have_cvs = 0 &&
- skip_test_ "this test requires cvs"
+ skip_ "this test requires cvs"
}
require_hg_()
@@ -83,14 +68,17 @@ require_hg_()
fi
test $have_hg = 0 &&
- skip_test_ "this test requires hg"
+ skip_ "this test requires hg"
}
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-
-# Don't clean up if $DEBUG is set.
-if test "${DEBUG+set}" != set; then
- trap 'st=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $st' 0
- trap '(exit $?); exit $?' 1 2 13 15
-fi
+# Call this with a list of programs under test immediately after
+# sourcing init.sh.
+print_ver_()
+{
+ if test "$VERBOSE" = yes; then
+ local i
+ for i in $*; do
+ env $i --version
+ done
+ fi
+}
diff --git a/tests/init.sh b/tests/init.sh
new file mode 100644
index 0000000..71c6516
--- /dev/null
+++ b/tests/init.sh
@@ -0,0 +1,474 @@
+# source this file; set up for tests
+
+# Copyright (C) 2009-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 3 of the License, 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/>.
+
+# Using this file in a test
+# =========================
+#
+# The typical skeleton of a test looks like this:
+#
+# #!/bin/sh
+# . "${srcdir=.}/init.sh"; path_prepend_ .
+# Execute some commands.
+# Note that these commands are executed in a subdirectory, therefore you
+# need to prepend "../" to relative filenames in the build directory.
+# Note that the "path_prepend_ ." is useful only if the body of your
+# test invokes programs residing in the initial directory.
+# For example, if the programs you want to test are in src/, and this test
+# script is named tests/test-1, then you would use "path_prepend_ ../src",
+# or perhaps export PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH"
+# to all tests via automake's TESTS_ENVIRONMENT.
+# Set the exit code 0 for success, 77 for skipped, or 1 or other for failure.
+# Use the skip_ and fail_ functions to print a diagnostic and then exit
+# with the corresponding exit code.
+# Exit $?
+
+# Executing a test that uses this file
+# ====================================
+#
+# Running a single test:
+# $ make check TESTS=test-foo.sh
+#
+# Running a single test, with verbose output:
+# $ make check TESTS=test-foo.sh VERBOSE=yes
+#
+# Running a single test, with single-stepping:
+# 1. Go into a sub-shell:
+# $ bash
+# 2. Set relevant environment variables from TESTS_ENVIRONMENT in the
+# Makefile:
+# $ export srcdir=../../tests # this is an example
+# 3. Execute the commands from the test, copy&pasting them one by one:
+# $ . "$srcdir/init.sh"; path_prepend_ .
+# ...
+# 4. Finally
+# $ exit
+
+ME_=`expr "./$0" : '.*/\(.*\)$'`
+
+# We use a trap below for cleanup. This requires us to go through
+# hoops to get the right exit status transported through the handler.
+# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit () { set +e; (exit $1); exit $1; }
+
+# Print warnings (e.g., about skipped and failed tests) to this file number.
+# Override by defining to say, 9, in init.cfg, and putting say,
+# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition
+# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
+# This is useful when using automake's parallel tests mode, to print
+# the reason for skip/failure to console, rather than to the .log files.
+: ${stderr_fileno_=2}
+
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; }
+skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
+framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; }
+
+# Sanitize this shell to POSIX mode, if possible.
+DUALCASE=1; export DUALCASE
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+ esac
+fi
+
+# We require $(...) support unconditionally.
+# We require a few additional shell features only when $EXEEXT is nonempty,
+# in order to support automatic $EXEEXT emulation:
+# - hyphen-containing alias names
+# - we prefer to use ${var#...} substitution, rather than having
+# to work around lack of support for that feature.
+# The following code attempts to find a shell with support for these features.
+# If the current shell passes the test, we're done. Otherwise, test other
+# shells until we find one that passes. If one is found, re-exec it.
+# If no acceptable shell is found, skip the current test.
+#
+# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that
+# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do.
+#
+# Use "9" to indicate success (rather than 0), in case some shell acts
+# like Solaris 10's /bin/sh but exits successfully instead of with status 2.
+
+# Eval this code in a subshell to determine a shell's suitability.
+# 10 - passes all tests; ok to use
+# 9 - ok, but enabling "set -x" corrupts app stderr; prefer higher score
+# ? - not ok
+gl_shell_test_script_='
+test $(echo y) = y || exit 1
+score_=10
+if test "$VERBOSE" = yes; then
+ test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9
+fi
+test -z "$EXEEXT" && exit $score_
+shopt -s expand_aliases
+alias a-b="echo zoo"
+v=abx
+ test ${v%x} = ab \
+ && test ${v#a} = bx \
+ && test $(a-b) = zoo \
+ && exit $score_
+'
+
+if test "x$1" = "x--no-reexec"; then
+ shift
+else
+ # Assume a working shell. Export to subshells (setup_ needs this).
+ gl_set_x_corrupts_stderr_=false
+ export gl_set_x_corrupts_stderr_
+
+ # Record the first marginally acceptable shell.
+ marginal_=
+
+ # Search for a shell that meets our requirements.
+ for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \
+ /bin/sh bash dash zsh pdksh fail
+ do
+ test "$re_shell_" = no_shell && continue
+
+ # If we've made it all the way to the sentinel, "fail" without
+ # finding even a marginal shell, skip this test.
+ if test "$re_shell_" = fail; then
+ test -z "$marginal_" && skip_ failed to find an adequate shell
+ re_shell_=$marginal_
+ break
+ fi
+
+ # When testing the current shell, simply "eval" the test code.
+ # Otherwise, run it via $re_shell_ -c ...
+ if test "$re_shell_" = __current__; then
+ # 'eval'ing this code makes Solaris 10's /bin/sh exit with
+ # $? set to 2. It does not evaluate any of the code after the
+ # "unexpected" first `('. Thus, we must run it in a subshell.
+ ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1
+ else
+ "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null
+ fi
+
+ st_=$?
+
+ # $re_shell_ works just fine. Use it.
+ test $st_ = 10 && break
+
+ # If this is our first marginally acceptable shell, remember it.
+ if test "$st_:$marginal_" = 9: ; then
+ marginal_="$re_shell_"
+ gl_set_x_corrupts_stderr_=true
+ fi
+ done
+
+ if test "$re_shell_" != __current__; then
+ # Found a usable shell. Preserve -v and -x.
+ case $- in
+ *v*x* | *x*v*) opts_=-vx ;;
+ *v*) opts_=-v ;;
+ *x*) opts_=-x ;;
+ *) opts_= ;;
+ esac
+ exec "$re_shell_" $opts_ "$0" --no-reexec "$@"
+ echo "$ME_: exec failed" 1>&2
+ exit 127
+ fi
+fi
+
+test -n "$EXEEXT" && shopt -s expand_aliases
+
+# Enable glibc's malloc-perturbing option.
+# This is useful for exposing code that depends on the fact that
+# malloc-related functions often return memory that is mostly zeroed.
+# If you have the time and cycles, use valgrind to do an even better job.
+: ${MALLOC_PERTURB_=87}
+export MALLOC_PERTURB_
+
+# This is a stub function that is run upon trap (upon regular exit and
+# interrupt). Override it with a per-test function, e.g., to unmount
+# a partition, or to undo any other global state changes.
+cleanup_ () { :; }
+
+if ( diff --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
+ compare () { diff -u "$@"; }
+elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
+ compare () { cmp -s "$@"; }
+else
+ compare () { cmp "$@"; }
+fi
+
+# An arbitrary prefix to help distinguish test directories.
+testdir_prefix_ () { printf gt; }
+
+# Run the user-overridable cleanup_ function, remove the temporary
+# directory and exit with the incoming value of $?.
+remove_tmp_ ()
+{
+ __st=$?
+ cleanup_
+ # cd out of the directory we're about to remove
+ cd "$initial_cwd_" || cd / || cd /tmp
+ chmod -R u+rwx "$test_dir_"
+ # If removal fails and exit status was to be 0, then change it to 1.
+ rm -rf "$test_dir_" || { test $__st = 0 && __st=1; }
+ exit $__st
+}
+
+# Given a directory name, DIR, if every entry in it that matches *.exe
+# contains only the specified bytes (see the case stmt below), then print
+# a space-separated list of those names and return 0. Otherwise, don't
+# print anything and return 1. Naming constraints apply also to DIR.
+find_exe_basenames_ ()
+{
+ feb_dir_=$1
+ feb_fail_=0
+ feb_result_=
+ feb_sp_=
+ for feb_file_ in $feb_dir_/*.exe; do
+ # If there was no *.exe file, or there existed a file named "*.exe" that
+ # was deleted between the above glob expansion and the existence test
+ # below, just skip it.
+ test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \
+ && continue
+ # Exempt [.exe, since we can't create a function by that name, yet
+ # we can't invoke [ by PATH search anyways due to shell builtins.
+ test "x$feb_file_" = "x$feb_dir_/[.exe" && continue
+ case $feb_file_ in
+ *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;;
+ *) # Remove leading file name components as well as the .exe suffix.
+ feb_file_=${feb_file_##*/}
+ feb_file_=${feb_file_%.exe}
+ feb_result_="$feb_result_$feb_sp_$feb_file_";;
+ esac
+ feb_sp_=' '
+ done
+ test $feb_fail_ = 0 && printf %s "$feb_result_"
+ return $feb_fail_
+}
+
+# Consider the files in directory, $1.
+# For each file name of the form PROG.exe, create an alias named
+# PROG that simply invokes PROG.exe, then return 0. If any selected
+# file name or the directory name, $1, contains an unexpected character,
+# define no alias and return 1.
+create_exe_shims_ ()
+{
+ case $EXEEXT in
+ '') return 0 ;;
+ .exe) ;;
+ *) echo "$0: unexpected \$EXEEXT value: $EXEEXT" 1>&2; return 1 ;;
+ esac
+
+ base_names_=`find_exe_basenames_ $1` \
+ || { echo "$0 (exe_shim): skipping directory: $1" 1>&2; return 0; }
+
+ if test -n "$base_names_"; then
+ for base_ in $base_names_; do
+ alias "$base_"="$base_$EXEEXT"
+ done
+ fi
+
+ return 0
+}
+
+# Use this function to prepend to PATH an absolute name for each
+# specified, possibly-$initial_cwd_-relative, directory.
+path_prepend_ ()
+{
+ while test $# != 0; do
+ path_dir_=$1
+ case $path_dir_ in
+ '') fail_ "invalid path dir: '$1'";;
+ /*) abs_path_dir_=$path_dir_;;
+ *) abs_path_dir_=`cd "$initial_cwd_/$path_dir_" && echo "$PWD"` \
+ || fail_ "invalid path dir: $path_dir_";;
+ esac
+ case $abs_path_dir_ in
+ *:*) fail_ "invalid path dir: '$abs_path_dir_'";;
+ esac
+ PATH="$abs_path_dir_:$PATH"
+
+ # Create an alias, FOO, for each FOO.exe in this directory.
+ create_exe_shims_ "$abs_path_dir_" \
+ || fail_ "something failed (above): $abs_path_dir_"
+ shift
+ done
+ export PATH
+}
+
+setup_ ()
+{
+ if test "$VERBOSE" = yes; then
+ # Test whether set -x may cause the selected shell to corrupt an
+ # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh
+ # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5.
+ # If enabling verbose output this way would cause trouble, simply
+ # issue a warning and refrain.
+ if $gl_set_x_corrupts_stderr_; then
+ warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr"
+ else
+ set -x
+ fi
+ fi
+
+ initial_cwd_=$PWD
+ fail=0
+
+ pfx_=`testdir_prefix_`
+ test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
+ || fail_ "failed to create temporary directory in $initial_cwd_"
+ cd "$test_dir_"
+
+ # As autoconf-generated configure scripts do, ensure that IFS
+ # is defined initially, so that saving and restoring $IFS works.
+ gl_init_sh_nl_='
+'
+ IFS=" "" $gl_init_sh_nl_"
+
+ # This trap statement, along with a trap on 0 below, ensure that the
+ # temporary directory, $test_dir_, is removed upon exit as well as
+ # upon receipt of any of the listed signals.
+ for sig_ in 1 2 3 13 15; do
+ eval "trap 'Exit $(expr $sig_ + 128)' $sig_"
+ done
+}
+
+# Create a temporary directory, much like mktemp -d does.
+# Written by Jim Meyering.
+#
+# Usage: mktempd_ /tmp phoey.XXXXXXXXXX
+#
+# First, try to use the mktemp program.
+# Failing that, we'll roll our own mktemp-like function:
+# - try to get random bytes from /dev/urandom
+# - failing that, generate output from a combination of quickly-varying
+# sources and gzip. Ignore non-varying gzip header, and extract
+# "random" bits from there.
+# - given those bits, map to file-name bytes using tr, and try to create
+# the desired directory.
+# - make only $MAX_TRIES_ attempts
+
+# Helper function. Print $N pseudo-random bytes from a-zA-Z0-9.
+rand_bytes_ ()
+{
+ n_=$1
+
+ # Maybe try openssl rand -base64 $n_prime_|tr '+/=\012' abcd first?
+ # But if they have openssl, they probably have mktemp, too.
+
+ chars_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
+ dev_rand_=/dev/urandom
+ if test -r "$dev_rand_"; then
+ # Note: 256-length($chars_) == 194; 3 copies of $chars_ is 186 + 8 = 194.
+ dd ibs=$n_ count=1 if=$dev_rand_ 2>/dev/null \
+ | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_
+ return
+ fi
+
+ n_plus_50_=`expr $n_ + 50`
+ cmds_='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n'
+ data_=` (eval "$cmds_") 2>&1 | gzip `
+
+ # Ensure that $data_ has length at least 50+$n_
+ while :; do
+ len_=`echo "$data_"|wc -c`
+ test $n_plus_50_ -le $len_ && break;
+ data_=` (echo "$data_"; eval "$cmds_") 2>&1 | gzip `
+ done
+
+ echo "$data_" \
+ | dd bs=1 skip=50 count=$n_ 2>/dev/null \
+ | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_
+}
+
+mktempd_ ()
+{
+ case $# in
+ 2);;
+ *) fail_ "Usage: $ME DIR TEMPLATE";;
+ esac
+
+ destdir_=$1
+ template_=$2
+
+ MAX_TRIES_=4
+
+ # Disallow any trailing slash on specified destdir:
+ # it would subvert the post-mktemp "case"-based destdir test.
+ case $destdir_ in
+ /) ;;
+ */) fail_ "invalid destination dir: remove trailing slash(es)";;
+ esac
+
+ case $template_ in
+ *XXXX) ;;
+ *) fail_ \
+ "invalid template: $template_ (must have a suffix of at least 4 X's)";;
+ esac
+
+ # First, try to use mktemp.
+ d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
+ || fail=1
+
+ # The resulting name must be in the specified directory.
+ case $d in "$destdir_"*);; *) fail=1;; esac
+
+ # It must have created the directory.
+ test -d "$d" || fail=1
+
+ # It must have 0700 permissions. Handle sticky "S" bits.
+ perms=`ls -dgo "$d" 2>/dev/null|tr S -` || fail=1
+ case $perms in drwx------*) ;; *) fail=1;; esac
+
+ test $fail = 0 && {
+ echo "$d"
+ return
+ }
+
+ # If we reach this point, we'll have to create a directory manually.
+
+ # Get a copy of the template without its suffix of X's.
+ base_template_=`echo "$template_"|sed 's/XX*$//'`
+
+ # Calculate how many X's we've just removed.
+ template_length_=`echo "$template_" | wc -c`
+ nx_=`echo "$base_template_" | wc -c`
+ nx_=`expr $template_length_ - $nx_`
+
+ err_=
+ i_=1
+ while :; do
+ X_=`rand_bytes_ $nx_`
+ candidate_dir_="$destdir_/$base_template_$X_"
+ err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \
+ && { echo "$candidate_dir_"; return; }
+ test $MAX_TRIES_ -le $i_ && break;
+ i_=`expr $i_ + 1`
+ done
+ fail_ "$err_"
+}
+
+# If you want to override the testdir_prefix_ function,
+# or to add more utility functions, use this file.
+test -f "$srcdir/init.cfg" \
+ && . "$srcdir/init.cfg"
+
+setup_ "$@"
+# This trap is here, rather than in the setup_ function, because some
+# shells run the exit trap at shell function exit, rather than script exit.
+trap remove_tmp_ 0
diff --git a/tests/leading-comment b/tests/leading-comment
index 9d813bf..4d9b0d8 100755
--- a/tests/leading-comment
+++ b/tests/leading-comment
@@ -1,28 +1,15 @@
#!/bin/sh
# Test the (first?) fix of 2006-09-04.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f ChangeLog || framework_failure=1
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch f ChangeLog || framework_failure_
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
fail=0
diff --git a/tests/multiple-chlogs b/tests/multiple-chlogs
index e082428..8292b6f 100755
--- a/tests/multiple-chlogs
+++ b/tests/multiple-chlogs
@@ -1,17 +1,8 @@
#! /bin/sh
# Test vc-chlog with multiple changelogs.
-if test "$VERBOSE" = yes; then
- set -x
- vc-chlog --version
-fi
-
-. $srcdir/trap-setup
-
-mkdir -p $tmp && cd $tmp || {
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-}
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-chlog
# Let's see whether this system knows unidiff format.
# We assume that if diff doesn't, then patch also won't.
@@ -23,7 +14,6 @@ if ($diff -u empty empty) >/dev/null 2>&1; then
else
diff_u=$diff
skip_test_ "$diff -u does not work"
- (exit 77); exit 77
fi
run_vc_chlog ()
diff --git a/tests/no-star b/tests/no-star
index 7f71f27..1a2d1bd 100755
--- a/tests/no-star
+++ b/tests/no-star
@@ -1,33 +1,20 @@
#!/bin/sh
# Test the second fix of 2006-09-04.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f || framework_failure=1
-cat <<EOF > ChangeLog || framework_failure=1
+touch f || framework_failure_
+cat <<EOF > ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
* f: X.
EOF
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
fail=0
diff --git a/tests/no-vc b/tests/no-vc
index 1f64933..ab9a344 100755
--- a/tests/no-vc
+++ b/tests/no-vc
@@ -6,23 +6,10 @@
# to do this properly.
exit 0
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
-. $srcdir/trap-setup
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch ChangeLog || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch ChangeLog || framework_failure_
fail=0
diff --git a/tests/scalar b/tests/scalar
index 205ad17..d7516df 100755
--- a/tests/scalar
+++ b/tests/scalar
@@ -3,23 +3,15 @@
# Before, vc-dwim would insert a line like SCALAR(0xb1d360)
# in the commit log.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f || framework_failure=1
-( git init && git add . && git commit -m m . ) || framework_failure=1
-mkdir .git/c || framework_failure=1
-cat <<EOF >> .git/c/ChangeLog || framework_failure=1
+touch f || framework_failure_
+( git init && git add . && git commit -m m . ) || framework_failure_
+mkdir .git/c || framework_failure_
+cat <<EOF >> .git/c/ChangeLog || framework_failure_
2006-09-04 Jo R. User <address@hidden>
sum:X
@@ -33,17 +25,12 @@ cat <<EOF >> .git/c/ChangeLog || framework_failure=1
sum:g
* g: Y.
EOF
-ln -s .git/c/ChangeLog . || framework_failure=1
-( cd .git/c && git init && git add . && git commit -m m . ) ||
framework_failure=1
+ln -s .git/c/ChangeLog . || framework_failure_
+( cd .git/c && git init && git add . && git commit -m m . ) ||
framework_failure_
perl -pi -e '/X/ and print "\t* f: new\n";' \
- -e '/Y/ and print "\tgah\n"' .git/c/ChangeLog || framework_failure=1
-echo >> f || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+ -e '/Y/ and print "\tgah\n"' .git/c/ChangeLog || framework_failure_
+echo >> f || framework_failure_
fail=0
diff --git a/tests/subdir b/tests/subdir
index 6e9968a..7fed101 100755
--- a/tests/subdir
+++ b/tests/subdir
@@ -3,29 +3,16 @@
# when using git. See the diff_outputs_full_file_names method for why
# this is different. It's easy when run from the top level.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir s || framework_failure=1
-touch s/f s/ChangeLog || framework_failure=1
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir s || framework_failure_
+touch s/f s/ChangeLog || framework_failure_
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
fail=0
diff --git a/tests/subdir-cvs b/tests/subdir-cvs
index 8a2576a..915c398 100755
--- a/tests/subdir-cvs
+++ b/tests/subdir-cvs
@@ -3,34 +3,22 @@
# an .hg or .git repository is a little tricky internally.
# It "just works" when CVS is the version control system.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_cvs_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-repo=$pwd/$tmp/repo
-cvs -f -Q -d $repo init 2> /dev/null || framework_failure=1
+mkdir repo || framework_failure_
+repo=$PWD/repo
+cvs -f -Q -d $repo init 2> /dev/null || framework_failure_
-mkdir d || framework_failure=1
+mkdir d || framework_failure_
cd d
-mkdir s || framework_failure=1
-touch s/f s/ChangeLog || framework_failure=1
-cvs -f -Q -d $repo import -m msg m M M0 || framework_failure=1
-cvs -f -Q -d $repo co m || framework_failure=1
-cd m || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir s || framework_failure_
+touch s/f s/ChangeLog || framework_failure_
+cvs -f -Q -d $repo import -m msg m M M0 || framework_failure_
+cvs -f -Q -d $repo co m || framework_failure_
+cd m || framework_failure_
fail=0
diff --git a/tests/subdir-middle b/tests/subdir-middle
index 98be586..a24ad75 100755
--- a/tests/subdir-middle
+++ b/tests/subdir-middle
@@ -2,37 +2,24 @@
# Given a 3-level git tree with the working directory in the middle directory,
# and vc-dwim operating on a ChangeLog in the lowest level directory.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
ChangeLog=2/3/ChangeLog
-mkdir -p 2/3 || framework_failure=1
-touch 2/3/f $ChangeLog || framework_failure=1
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
+mkdir -p 2/3 || framework_failure_
+touch 2/3/f $ChangeLog || framework_failure_
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
-cat <<EOF > $ChangeLog || framework_failure=1
+cat <<EOF > $ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
* f: X.
EOF
-echo z > 2/3/f || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+echo z > 2/3/f || framework_failure_
fail=0
cd 2
diff --git a/tests/symlinked-changelog b/tests/symlinked-changelog
index 2a4c106..6d930b6 100755
--- a/tests/symlinked-changelog
+++ b/tests/symlinked-changelog
@@ -1,23 +1,15 @@
#!/bin/sh
# Test the symlinked ChangeLog feature.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_bzr_
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir d m || framework_failure=1
-touch m/f || framework_failure=1
-cat <<EOF > d/ChangeLog || framework_failure=1
+mkdir d m || framework_failure_
+touch m/f || framework_failure_
+cat <<EOF > d/ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
EOF
@@ -27,20 +19,15 @@ HOME=`pwd`
export HOME
bzr whoami 'U. Ser <address@hidden>'
-(cd m && bzr init && bzr add . && bzr ci -m m . ) || framework_failure=1
+(cd m && bzr init && bzr add . && bzr ci -m m . ) || framework_failure_
ln -s ../d/ChangeLog m
echo a >> m/f
-(cd d && git init && git add . && git commit -m m . ) || framework_failure=1
-cat <<EOF >> d/ChangeLog || framework_failure=1
+(cd d && git init && git add . && git commit -m m . ) || framework_failure_
+cat <<EOF >> d/ChangeLog || framework_failure_
* f: X.
EOF
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
fail=0
(cd m && vc-dwim ChangeLog) > out || fail=1
diff --git a/tests/t-vc-chlog b/tests/t-vc-chlog
index de88aef..adf376c 100755
--- a/tests/t-vc-chlog
+++ b/tests/t-vc-chlog
@@ -1,17 +1,8 @@
#! /bin/sh
# Test vc-chlog.
-if test "$VERBOSE" = yes; then
- set -x
- vc-chlog --version
-fi
-
-. $srcdir/trap-setup
-
-mkdir -p $tmp && cd $tmp || {
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-}
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-chlog
# Let's see whether this system knows unidiff format.
# We assume that if diff doesn't, then patch also won't.
diff --git a/tests/two-line-attr b/tests/two-line-attr
index fb5af99..b1862f7 100755
--- a/tests/two-line-attr
+++ b/tests/two-line-attr
@@ -1,28 +1,15 @@
#!/bin/sh
# Ensure that a two-line ChangeLog attribution is accepted.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f ChangeLog || framework_failure=1
-git init > /dev/null || framework_failure=1
-git add . || framework_failure=1
-git commit -m m . > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch f ChangeLog || framework_failure_
+git init > /dev/null || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
fail=0
diff --git a/tests/two-vc b/tests/two-vc
index b7b6304..65a338a 100755
--- a/tests/two-vc
+++ b/tests/two-vc
@@ -1,38 +1,25 @@
#!/bin/sh
# Fail if two ChangeLog files use different version control systems.
-if test "$VERBOSE" = yes; then
- set -x
- vc-dwim --version
-fi
-
-. $srcdir/trap-setup
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
require_git_
require_cvs_
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir -p c/sub/CVS g || framework_failure=1
-touch c/sub/f g/f || framework_failure=1
-cat <<EOF > g/ChangeLog || framework_failure=1
+mkdir -p c/sub/CVS g || framework_failure_
+touch c/sub/f g/f || framework_failure_
+cat <<EOF > g/ChangeLog || framework_failure_
2006-09-04 Jim Meyering <address@hidden>
* f: X.
EOF
-cp g/ChangeLog c/sub || framework_failure=1
-
-(cd g && git init > /dev/null) || framework_failure=1
-(cd g && git add . > /dev/null) || framework_failure=1
-(cd g && git commit -m m . ) > /dev/null || framework_failure=1
-mv c/sub g || framework_failure=1
+cp g/ChangeLog c/sub || framework_failure_
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+(cd g && git init > /dev/null) || framework_failure_
+(cd g && git add . > /dev/null) || framework_failure_
+(cd g && git commit -m m . ) > /dev/null || framework_failure_
+mv c/sub g || framework_failure_
fail=0
--
1.7.5.320.g20a15
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-vc-dwim] [PATCH] tests: update to use gnulib's init.sh,
Jim Meyering <=