smoke 4.06 KB
Newer Older
1 2 3
#!/bin/sh
set -e

4 5 6 7 8 9 10 11 12 13 14 15 16
cleanup() {
	cd $PDIR

	#Clean up after smoke-setup
	cleanup_file=debian/tests/pkg-perl/smoke-cleanup
	if [ -x $cleanup_file ]
	then
	    ( export TDIR; $cleanup_file )
	fi

	rm -rf $TDIR
}

17 18 19
TEMP=${ADTTMP:-${TMPDIR:-/tmp}}

TDIR=$(mktemp -d $TEMP/smokeXXXXXX)
20 21 22 23 24

PDIR=`pwd`

trap cleanup EXIT

25 26 27 28 29
file_list=debian/tests/pkg-perl/smoke-files
if [ ! -r $file_list ]; then
    # backward compatibility squared for now
    file_list=debian/tests/pkg-perl/test-files
fi
30 31 32 33 34
if [ ! -r $file_list ]; then
    # backward compatibility for now
    file_list=debian/tests/test-files
fi

35 36 37
export AUTOMATED_TESTING=1
export NONINTERACTIVE_TESTING=1

38
# overridable with smoke-env
39
PKG_PERL_PROVE_ARGS="--verbose --recurse --merge"
40
PKG_PERL_XVFB_ARGS="-a"
41

42 43 44 45
env_list=debian/tests/pkg-perl/smoke-env
if [ ! -r $env_list ]; then
    env_list=debian/tests/pkg-perl/env-smoke
fi
46 47 48 49
if [ -r $env_list ]; then
    eval $(sed '/^ *\(#\|$\)/d; s/^/export /' $env_list)
fi

50
if [ -r $file_list ]; then
51
    egrep -v '^ *(#|$)' $file_list | while read file; do
52
	[ -r $file ] && cp --parents -a $file $TDIR
53 54
    done
else
55 56
    [ -d t ] && cp -a t $TDIR
    [ -f test.pl ] && cp -a test.pl $TDIR
57
fi
58

59 60 61 62
skip_list=debian/tests/pkg-perl/smoke-skip
if [ ! -r $skip_list ]; then
    skip_list=debian/tests/pkg-perl/skip-smoke
fi
63 64 65 66 67 68
if [ -r $skip_list ]
then
    egrep -v '^ *(#|$)' $skip_list | while read file; do
        rm -f $TDIR/$file
    done
else
69
    # common nuisances, no value with runtime tests
70 71 72 73
    rm -f $TDIR/t/*pod.t
    rm -f $TDIR/t/*pod[-_]cov*.t # coverage
    rm -f $TDIR/t/*pod[-_]syn*.t # syntax

74 75 76
    # these should ideally be conditional to RELEASE_TESTING but normally aren't
    # example: libbest-perl_0.15-1
    rm -f $TDIR/t/boilerplate.t
77 78

    # we're not interested in perlcritic regressions
79
    # example: libhttp-body-perl
80
    rm -f $TDIR/t/*critic*.t
81

82 83
    # example: liborlite-statistics-perl
    rm -f $TDIR/t/97_meta.t
84

85
    # example: libfile-userconfig-perl
86
    rm -f $TDIR/t/99_pmv.t
87

88 89 90 91 92 93 94 95 96
    # we test compile all the modules separately
    rm -f $TDIR/t/*compile*.t
    # Dist::Zilla generates these sometimes
    # example: libmoosex-has-sugar-perl
    rm -f $TDIR/t/00-compile/*.t

    # various "author" tests not meant to be run with the build dependencies
    rm -f $TDIR/t/*author*.t
    rm -f $TDIR/t/*author/*.t
97
fi
98

99 100 101
# for Test::Pod
mkdir -p $TDIR/blib

102 103 104
# for 'use blib'
mkdir -p $TDIR/blib/lib $TDIR/blib/arch

105
# for misc tests that need something in lib or blib/lib/
106
# cf. libapache-authenhook-perl
107 108 109 110 111 112 113 114 115 116 117 118 119 120
mkdir -p $TDIR/lib/Debian/pkgperl
mkdir -p $TDIR/blib/lib/Debian/pkgperl
cat <<'EOF' > $TDIR/lib/Debian/pkgperl/Foobar.pm
package Debian::pkgperl::Foobar;
our $VERSION = '0.01';
1;
__END__
=head1 NAME

Debian::pkgperl::Foobar - dummy module for test checkers

=cut
EOF
cp $TDIR/lib/Debian/pkgperl/Foobar.pm $TDIR/blib/lib/Debian/pkgperl
121

122 123
if [ ! -e $TDIR/MANIFEST ]; then
    cat <<'EOF' > $TDIR/MANIFEST
124 125
lib/Debian/pkgperl/Foobar.pm
EOF
126
fi
127

128 129 130
if [ ! -e $TDIR/MANIFEST.SKIP ]; then
    cp /dev/null $TDIR/MANIFEST.SKIP
fi
131

132 133 134 135
# this is intended to be a last resort, please use it responsibly
setup_file=debian/tests/pkg-perl/smoke-setup
if [ -x $setup_file ]
then
136
    ( export TDIR; $setup_file )
137 138 139 140 141 142 143 144

    # Evaluate skip list a second time since smoke-setup might have
    # generated some of the to-be-skipped files.
    if [ -r $skip_list ]; then
        egrep -v '^ *(#|$)' $skip_list | while read file; do
            rm -f $TDIR/$file
        done
    fi
145 146
fi

147
tests_file=$(pwd)/debian/tests/pkg-perl/smoke-tests
148
cd $TDIR
149
if [ -r $tests_file ]; then
150
    test_targets=$(eval ls -d $(egrep -v '^#' $tests_file) 2>/dev/null || true)
151
fi
152

153
if command -v xvfb-run >/dev/null
154
then
155
    XVFB=xvfb-run
156 157
else
    XVFB=
158 159
    PKG_PERL_XVFB_ARGS=
    PKG_PERL_XVFB_SERVER_ARGS=
160 161
fi

162
if [ -z "$test_targets" ] && [ -d t ]; then test_targets=t; fi
163 164

if [ ! -n "$test_targets" ]; then
165
    echo 'Nothing to prove, skipping.'
166
else
167
    $XVFB $PKG_PERL_XVFB_ARGS ${PKG_PERL_XVFB_SERVER_ARGS:+-s} ${PKG_PERL_XVFB_SERVER_ARGS:+"$PKG_PERL_XVFB_SERVER_ARGS"} prove -I"$TDIR" --blib $PKG_PERL_PROVE_ARGS $test_targets 2>&1
168
fi
169

170
if [ -f test.pl ]; then $XVFB perl -I"$TDIR" ./test.pl; fi 2>&1
171