5 TEST_STDERR_LOG=/tmp/dbictest.stderr
6 TIMEOUT_CMD="/usr/bin/timeout --kill-after=9.5m --signal=TERM 9m"
8 echo_err() { echo "$@" 1>&2 ; }
10 if [[ "$TRAVIS" != "true" ]] ; then
11 echo_err "Running this script makes no sense outside of travis-ci"
15 tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; }
19 ========================== CI System information ============================
22 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
35 = Network Configuration
38 = Network Sockets Status
39 $(sudo netstat -an46p | grep -Pv '\s(CLOSING|(FIN|TIME|CLOSE)_WAIT.?|LAST_ACK)\s')
45 $(env | grep -P 'TEST|HARNESS|MAKE|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
49 ============================================================================="
53 echo_err -n "$(tstamp) $1 ... "
59 PRMETER_PIDFILE="$(tempfile)_$SECONDS"
60 # the double bash is to hide the job control messages
61 bash -c "bash -c 'echo \$\$ >> $PRMETER_PIDFILE; while true; do sleep 10; echo -n \"\${SECONDS}s ... \"; done' &"
63 LASTOUT=$( eval "$2" 2>&1 ) || LASTEXIT=$?
66 for p in $(cat "$PRMETER_PIDFILE"); do kill $p ; done
68 DELTA_TIME=$(( $SECONDS - $START_TIME ))
70 if [[ "$LASTEXIT" != "0" ]] ; then
71 if [[ -z "$3" ]] ; then
72 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
73 echo_err "Command executed:"
75 echo_err "STDOUT+STDERR:"
81 echo_err "done (took ${DELTA_TIME}s)"
89 # Need to do this at every step, the sources list may very well have changed
90 run_or_err "Updating APT available package list" "sudo apt-get update"
92 run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs"
96 # once --verbose is set, --no-verbose can't disable it
98 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
102 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
105 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
106 ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}
108 if [[ "$LASTEXIT" != "0" ]] ; then
109 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
115 # throw away warnings, up-to-date diag, ascii art, convert to modnames
117 s/^.*?is up to date.*$//;
120 s/\-[^\-]+$/ /; # strip version part
124 # throw away what was in $@
126 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
133 parallel_installdeps_notest() {
134 if [[ -z "$@" ]] ; then return; fi
136 # one module spec per line
137 MODLIST="$(printf '%s\n' "$@")"
139 # We want to trap the output of each process and serially append them to
140 # each other as opposed to just dumping a jumbled up mass-log that would
141 # need careful unpicking by a human
143 # While cpanm does maintain individual buildlogs in more recent versions,
144 # we are not terribly interested in trying to figure out which log is which
145 # dist. The verbose-output + trap STDIO technique is vastly superior in this
148 # Explanation of inline args:
150 # [09:38] <T> you need a $0
151 # [09:38] <G> hence the _
152 # [09:38] <G> bash -c '...' _
153 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
154 # [09:39] <G> or --, yes
155 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
157 run_or_err "Installing (without testing) $(echo $MODLIST)" \
160 | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\
161 'OUT=\$(maint/getstatus $TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
162 'giant space monkey penises'
167 if [[ -z "$@" ]] ; then return; fi
169 MODLIST=$(printf "%q " "$@" | perl -pe 's/^\s+|\s+$//g')
171 local -x HARNESS_OPTIONS
173 HARNESS_OPTIONS="j$NUMTHREADS"
175 if ! run_or_err "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ($MODLIST)" "_dep_inst_with_test $MODLIST" quiet_fail ; then
176 local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")"
179 POSTMORTEM="$POSTMORTEM$(
181 echo "Depinstall of $MODLIST under $HARNESS_OPTIONS parallel testing $errlog"
185 run_or_err "Retrying same $# modules without parallel testing" "_dep_inst_with_test $MODLIST"
188 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
191 _dep_inst_with_test() {
192 if [[ "$DEVREL_DEPS" == "true" ]] ; then
193 # --dev is already part of CPANM_OPT
194 LASTCMD="$TIMEOUT_CMD cpanm $@"
197 LASTCMD="$TIMEOUT_CMD cpan $@"
200 # older perls do not have a CPAN which can exit with error on failed install
205 $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x
206 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
210 $mod = q{List::Util} if $mod eq q{Scalar::List::Utils};
212 eval qq{require($mod)} or ( print $@ and exit 1)
214 ' "$m" 2> /dev/null ; then
215 echo -e "$m installation seems to have failed"
222 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
224 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }