5 TEST_STDERR_LOG=/tmp/dbictest.stderr
7 echo_err() { echo "$@" 1>&2 ; }
9 if [[ "$TRAVIS" != "true" ]] ; then
10 echo_err "Running this script makes no sense outside of travis-ci"
14 tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; }
17 echo_err -n "$(tstamp) $1 ... "
21 LASTOUT=$( bash -c "$2" 2>&1 ) || LASTEXIT=$?
22 DELTA_TIME=$(( $SECONDS - $START_TIME ))
24 if [[ "$LASTEXIT" != "0" ]] ; then
25 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
26 echo_err "Command executed:"
28 echo_err "STDOUT+STDERR:"
33 echo_err "done (took ${DELTA_TIME}s)"
38 # once --verbose is set, --no-verbose can't disable it
40 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
44 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
47 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
48 ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}")
50 if [[ "$LASTEXIT" != "0" ]] ; then
51 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
57 # throw away ascii art, convert to modnames
58 PQ=$(perl -p -e 's/^[^a-z]+//i; s/\-[^\-]+$/ /; s/\-/::/g' <<< "$OUT")
60 # throw away what was in $@
62 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
69 parallel_installdeps_notest() {
70 if [[ -z "$@" ]] ; then return; fi
72 # one module spec per line
73 MODLIST="$(printf '%s\n' "$@")"
75 # The reason we do things so "non-interactively" is that xargs -P will have the
76 # latest cpanm instance overwrite the buildlog. There seems to be no way to
77 # specify a custom buildlog, hence we just collect the verbose output
78 # and display it in case of "worker" failure
80 # Explanation of inline args:
82 # [09:38] <T> you need a $0
83 # [09:38] <G> hence the _
84 # [09:38] <G> bash -c '...' _
85 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
86 # [09:39] <G> or --, yes
87 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
89 run_or_err "Installing (without testing) $(echo $MODLIST)" \
92 | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\
93 'OUT=\$(cpanm --notest --no-man-pages \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
94 'giant space monkey penises'
99 if [[ -z "$@" ]] ; then return; fi
101 echo_err "$(tstamp) Processing dependencies: $@"
103 local -x HARNESS_OPTIONS
105 HARNESS_OPTIONS="j$NUMTHREADS"
107 echo_err -n "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ... "
111 LASTOUT=$( cpan_inst "$@" ) || LASTEXIT=$?
112 DELTA_TIME=$(( $SECONDS - $START_TIME ))
114 if [[ "$LASTEXIT" = "0" ]] ; then
115 echo_err "done (took ${DELTA_TIME}s)"
117 local errlog="after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel installfail" <<< "$LASTOUT")"
118 echo_err -n "failed ($errlog) retrying with sequential testing ... "
119 POSTMORTEM="$POSTMORTEM$(
121 echo "Depinstall under $HARNESS_OPTIONS parallel testing failed $errlog (while attempting install of $@)"
127 LASTOUT=$( cpan_inst "$@" ) || LASTEXIT=$?
128 DELTA_TIME=$(( $SECONDS - $START_TIME ))
130 if [[ "$LASTEXIT" = "0" ]] ; then
131 echo_err "done (took ${DELTA_TIME}s)"
133 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
134 echo_err "STDOUT+STDERR:"
140 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
144 /usr/bin/timeout --kill-after=9.5m --signal=TERM 9m cpan "$@" 2>&1
146 # older perls do not have a CPAN which can exit with error on failed install
150 eval ( q{require } . (
151 $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x
152 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
154 ) ) or ( print $@ and exit 1)' "$m" 2> /dev/null ; then
156 echo -e "$m installation seems to have failed"
162 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
164 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }