25a35ff67500682495f75e729b4c136403e03452
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 40_script.bash
1 #!/bin/bash
2
3 # this file is executed in a subshell - set up the common stuff
4 source maint/travis-ci_scripts/common.bash
5
6 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then exit 0 ; fi
7
8 run_harness_tests() {
9   local -x HARNESS_OPTIONS=c:j$VCPU_USE
10   # if we run under docker (! have_sudo) the logic below won't work
11   # it seems as if ulimit acts globally, across the entire OS
12   # and is thus not served properly by a localised `ps xH`
13   if [[ "$VCPU_USE" == 1 ]] && have_sudo ; then
14     ulim=$(( ( $(ps xH | wc -l) - 3 ) + 4 )) # (real count excluding header + ps + wc) + space for ( make + tee + harness + <actual test> )
15     echo_err "$(tstamp) Setting process/thread limit to $ulim"
16     ulimit -u $ulim
17     sleep 5 # needed to settle things down a bit
18   fi
19   make test 2> >(tee "$TEST_STDERR_LOG")
20 }
21
22 # announce everything we have on this box
23 TRAVIS="" perl -Ilib t/00describe_environment.t >/dev/null
24
25 TEST_T0=$SECONDS
26 if [[ "$CLEANTEST" = "true" ]] ; then
27   echo_err "$(tstamp) Running tests with plain \`make test\`"
28   run_or_err "Prepare blib" "make pure_all"
29   run_harness_tests
30 else
31   PROVECMD="prove -lrswj$VCPU_USE xt t"
32
33   # FIXME - temporary, until Package::Stash is fixed
34   if perl -M5.010 -e 1 &>/dev/null ; then
35     PROVECMD="$PROVECMD -T"
36   fi
37
38   # List every single SKIP/TODO when they are visible
39   if [[ "$VCPU_USE" == 1 ]] ; then
40     PROVECMD="$PROVECMD --directives"
41   fi
42
43   echo_err "$(tstamp) running tests with \`$PROVECMD\`"
44   $PROVECMD 2> >(tee "$TEST_STDERR_LOG")
45 fi
46 TEST_T1=$SECONDS
47
48 if \
49    [[ -z "$DBIC_TRACE" ]] \
50 && [[ -z "$DBIC_MULTICREATE_DEBUG" ]] \
51 && [[ -z "$DBICTEST_DEBUG_CONCURRENCY_LOCKS" ]] \
52 && [[ -z "$DBICTEST_VERSION_WARNS_INDISCRIMINATELY" ]] \
53 && [[ -s "$TEST_STDERR_LOG" ]] ; then
54   STDERR_LOG_SIZE=$(wc -l < "$TEST_STDERR_LOG")
55
56   # prepend STDERR log
57   POSTMORTEM="$(
58     echo
59     echo "Test run produced $STDERR_LOG_SIZE lines of output on STDERR:"
60     echo "============================================================="
61     cat "$TEST_STDERR_LOG"
62     echo "============================================================="
63     echo "End of test run STDERR output ($STDERR_LOG_SIZE lines)"
64     echo
65     echo
66   )$POSTMORTEM"
67 fi
68
69 echo
70 echo "${POSTMORTEM:- \o/ No notable smoke run issues \o/ }"
71 echo
72 echo "$(tstamp) Testing took a total of $(( $TEST_T1 - $TEST_T0 ))s"
73 if [[ -n "$INSTALLDEPS_OUT" ]] ; then
74   echo "$(tstamp) Full dep install log at $(/usr/bin/perl /usr/bin/nopaste -q -s Shadowcat -d DepInstall <<< "$INSTALLDEPS_OUT")"
75 fi
76 echo