X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Ftravis-ci_scripts%2Fcommon.bash;h=691323a98e2e75dffefbbbbe69207a2051f878d1;hb=e1ab2f7a869eaeffd751ee2431642591918bc2a3;hp=ab5c29404a7fffb3635cfb8bade7f5bcf16c688b;hpb=71dd2ecc010836cbbe91e4bf7d4a84191a41dd39;p=dbsrgits%2FDBIx-Class.git diff --git a/maint/travis-ci_scripts/common.bash b/maint/travis-ci_scripts/common.bash index ab5c294..691323a 100755 --- a/maint/travis-ci_scripts/common.bash +++ b/maint/travis-ci_scripts/common.bash @@ -2,6 +2,8 @@ set -e +TEST_STDERR_LOG=/tmp/dbictest.stderr + echo_err() { echo "$@" 1>&2 ; } if [[ "$TRAVIS" != "true" ]] ; then @@ -20,7 +22,12 @@ run_or_err() { DELTA_TIME=$(( $SECONDS - $START_TIME )) if [[ "$LASTEXIT" != "0" ]] ; then - echo_err -e "FAILED !!! (after ${DELTA_TIME}s)\nCommand executed:\n$2\nSTDOUT+STDERR:\n$LASTOUT" + echo_err "FAILED !!! (after ${DELTA_TIME}s)" + echo_err "Command executed:" + echo_err "$2" + echo_err "STDOUT+STDERR:" + echo_err "$LASTOUT" + return $LASTEXIT else echo_err "done (took ${DELTA_TIME}s)" @@ -30,21 +37,20 @@ run_or_err() { extract_prereqs() { # once --verbose is set, --no-verbose can't disable it # do this by hand - ORIG_CPANM_OPT="$PERL_CPANM_OPT" - PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose//' )" + local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )" # hack-hack-hack LASTEXIT=0 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \ || LASTEXIT=$? - PERL_CPANM_OPT="$ORIG_CPANM_OPT" - OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!} ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}") - if [[ "$LASTEXIT" != "0" ]] || [[ -n "$ERR" ]] ; then - echo_err "$(echo -e "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:\n$ERR\n$OUT")" + if [[ "$LASTEXIT" != "0" ]] ; then + echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:" + echo_err "$ERR" + echo_err "$OUT" exit 1 fi @@ -55,15 +61,30 @@ extract_prereqs() { parallel_installdeps_notest() { if [[ -z "$@" ]] ; then return; fi - # flatten list into one string - MODLIST=$(echo "$@") + # one module spec per line + MODLIST="$(printf '%s\n' "$@")" # The reason we do things so "non-interactively" is that xargs -P will have the # latest cpanm instance overwrite the buildlog. There seems to be no way to # specify a custom buildlog, hence we just collect the verbose output - # and display it in case of failure - run_or_err "Installing (without testing) $MODLIST" \ - "echo $MODLIST | xargs -n 1 -P $NUMTHREADS cpanm --notest --no-man-pages" + # and display it in case of "worker" failure + # + # Explanation of inline args: + # + # [09:38] you need a $0 + # [09:38] hence the _ + # [09:38] bash -c '...' _ + # [09:39] I like -- because it's the magic that gnu getopts uses for somethign else + # [09:39] or --, yes + # [09:39] ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well + # + run_or_err "Installing (without testing) $(echo $MODLIST)" \ + "echo \\ +\"$MODLIST\" \\ + | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\ + 'OUT=\$(cpanm --notest --no-man-pages \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ + 'giant space monkey penises' + " }