2 # Remote testing of Automake tarballs made easy.
3 # This script requires Bash 4.x or later.
5 # Copyright (C) 2013 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # TODO: some documentation would be nice ...
25 fatal () { echo "$me: $*" >&2; exit 1; }
28 test_script=$HOME/.am-test/run
29 if test -f "$test_script" && test -x "$test_script"; then
32 nice -n19 ./configure && nice -n19 make -j10 check
38 while test $# -gt 0; do
40 -b|--batch) interactive=0;;
41 -c|--command) cmd=${2-}; shift;;
42 -*) fatal "'$1': invalid option";;
43 *) remote=$1; shift; break;;
47 [[ -n $remote ]] || fatal "no remote given"
49 if ((interactive)); then
51 AM_TESTSUITE_FAILED=yes
52 export AM_TESTSUITE_FAILED
53 # We should not modify the environment with which the failed
54 # tests have run, hence do not read ".profile", ".bashrc", and
56 exec bash --noprofile --norc -i
62 tarball=$(echo automake*.tar.xz)
65 *' '*) fatal "too many automake tarballs: $tarball";;
68 test -f $tarball || fatal "no automake tarball found"
70 distdir=${tarball%%.tar.xz}
72 env='PATH=$HOME/bin:$PATH'
74 env+=" TERM='$TERM' AM_COLOR_TESTS=always"
78 # $ ssh "command" arg-1 ... arg-2
79 # but doesn't work as expected. So we need the following hack
80 # to propagate the command line arguments to the remote shell.
84 *\'*) quoted_args+=" "$(printf '%s\n' "$1" | sed "s/'/'\\''/g");;
85 *) quoted_args+=" '$1'";;
93 scp $tarball $remote:tmp/
95 # Multiple '-t' to force tty allocation.
97 set -x; set -e; set -u;
100 if test -e $distdir; then
101 # Use 'perl', not only 'rm -rf', to correctly handle read-only
102 # files or directory. Fall back to 'rm' if something goes awry.
103 perl -e 'use File::Path qw/rmtree/; rmtree(\"$distdir\")' \
104 || rm -rf $distdir || exit 1
107 xz -dc $tarball | tar xf -
110 am_extra_acdir=$HOME/.am-test/extra-aclocal
111 am_extra_bindir=$HOME/.am-test/extra-bin
112 am_extra_setup=$HOME/.am-test/extra-setup.sh
113 if test -d "$am_extra_acdir"; then
114 export ACLOCAL_PATH=$am_extra_acdir${ACLOCAL_PATH+":$ACLOCAL_PATH"}
116 if test -d "$am_extra_bindir"; then
117 export PATH=$am_extra_bindir:$PATH
121 if test -f \"\$am_extra_setup\"; then
122 . \"\$am_extra_setup\"
124 ($cmd) || $do_on_error