3 if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
4 echo "This script can not be executed standalone - it can only be source()d" 1>&2
8 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
10 # we need a mirror that both has the standard index and a backpan version rolled
11 # into one, due to MDV testing
12 export CPAN_MIRROR="http://cpan.metacpan.org/"
14 PERL_CPANM_OPT="$PERL_CPANM_OPT --mirror $CPAN_MIRROR"
16 # do not set PERLBREW_CPAN_MIRROR - not all backpan-like mirrors have the perl tarballs
17 export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 HARNESS_TIMER=1 MAKEFLAGS="-j$VCPU_USE"
19 # try CPAN's latest offering if requested
20 if [[ "$DEVREL_DEPS" == "true" ]] ; then
22 PERL_CPANM_OPT="$PERL_CPANM_OPT --dev"
26 # Fixup CPANM_OPT to behave more like a traditional cpan client
27 export PERL_CPANM_OPT="--verbose --no-interactive --no-man-pages $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
29 if [[ -n "$BREWVER" ]] ; then
31 # since perl 5.14 a perl can safely be built concurrently with -j$large
32 # (according to brute force testing and my power bill)
33 if [[ "$BREWVER" =~ [A-Za-z] ]] || perl -Mversion -e "exit !!(version->new(q($BREWVER)) < 5.014)" ; then
34 perlbrew_jopt="$VCPU_USE"
40 if [[ "$BREWVER" == "cperl-master" ]] ; then
41 git clone --single-branch --depth=1 --branch=master https://github.com/perl11/cperl /tmp/cperl-master
42 BREWSRC="/tmp/cperl-master"
44 # FFS perlbrew ( see http://wollmers-perl.blogspot.de/2015/10/install-cperl-with-perlbrew.html )
45 wget -qO- https://github.com/perl11/cperl/archive/$BREWVER.tar.gz > /tmp/cperl-$BREWVER.tar.gz
46 BREWSRC="/tmp/cperl-$BREWVER.tar.gz"
48 elif [[ "$BREWVER" == "schmorp_stableperl" ]] ; then
49 BREWSRC="http://stableperl.schmorp.de/dist/stableperl-5.22.0-1.001.tar.gz"
52 run_or_err "Compiling/installing Perl $BREWVER (without testing, using ${perlbrew_jopt:-1} threads, may take up to 5 minutes)" \
53 "perlbrew install --as $BREWVER --notest --noman --verbose $BREWOPTS -j${perlbrew_jopt:-1} $BREWSRC"
55 # FIXME work around https://github.com/perl11/cperl/issues/144
56 # (still affecting 5.22.3)
57 if is_cperl && ! [[ -f ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] ; then
58 ln -s ~/perl5/perlbrew/perls/$BREWVER/bin/cperl ~/perl5/perlbrew/perls/$BREWVER/bin/perl || /bin/true
61 # can not do 'perlbrew use' in the run_or_err subshell above, or a $()
62 # furthermore some versions of `perlbrew use` return 0 regardless of whether
63 # the perl is found (won't be there unless compilation suceeded, wich *ALSO* returns 0)
64 perlbrew use $BREWVER || /bin/true
67 ! [[ -x ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] \
68 || [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]]
70 echo_err "Unable to switch to $BREWVER - compilation failed...?"
75 # no brewver - this means a travis perl, which means we want to clean up
76 # the presently installed libs
77 elif [[ "$CLEANTEST" == "true" ]] && [[ "$POISON_ENV" != "true" ]] ; then
81 if [[ "$POISON_ENV" = "true" ]] ; then
82 # create a perlbrew-specific local lib
83 perlbrew lib create travis-local
84 perlbrew use "$( perlbrew use | grep -oP '(?<=Currently using ).+' )@travis-local"
85 echo_err "POISON_ENV active - adding a local lib: $(perlbrew use)"
88 # configure CPAN.pm - older versions go into an endless loop
89 # when trying to autoconf themselves
92 require CPAN::FirstTime;
93 *CPAN::FirstTime::conf_sites = sub {};
95 \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
96 \$CPAN::Config->{halt_on_failure} = $( is_cperl && echo -n 0 || echo -n 1 );
99 run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"
102 # These envvars are always set, more *maybe* below
103 export DBIC_SHUFFLE_UNORDERED_RESULTSETS=1
105 # bogus nonexisting DBI_*
106 export DBI_DSN="dbi:ODBC:server=NonexistentServerAddress"
107 export DBI_DRIVER="ADO"
109 # some people do in fact set this - boggle!!!
110 # it of course won't work before 5.8.4
111 if perl -M5.008004 -e 1 &>/dev/null ; then
112 export PERL_STRICTURES_EXTRA=1
116 # poison the environment
117 if [[ "$POISON_ENV" = "true" ]] ; then
121 [[ "$CLEANTEST" == "true" ]] && toggle_vars+=( BREAK_CC )
123 for var in "${toggle_vars[@]}" ; do
124 if [[ -z "${!var}" ]] ; then
126 echo "POISON_ENV: setting $var to 'true'"
130 # look through lib, find all mentioned DBIC* ENVvars and set them to true and see if anything explodes
131 toggle_booleans=( $( grep -ohP '\bDBIC_[0-9_A-Z]+' -r lib/ --exclude-dir Optional | sort -u | grep -vP '^(DBIC_TRACE(_PROFILE)?|DBIC_.+_DEBUG)$' ) )
133 # some extra pollutants
135 DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION \
136 DBICTEST_SQLITE_USE_FILE \
137 DBICTEST_RUN_ALL_TESTS \
138 DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER \
141 # if we have Moose - try to run everything under replicated
142 # FIXME - when switching to Moo kill this
143 if [[ "$CLEANTEST" != "true" ]] && perl -M5.008003 -e 1 &>/dev/null ; then
144 toggle_booleans+=( DBICTEST_VIA_REPLICATED )
147 for var in "${toggle_booleans[@]}"
149 if [[ -z "${!var}" ]] ; then
151 echo "POISON_ENV: setting $var to 1"
155 echo "POISON_ENV: setting PERL_UNICODE=SAD"
156 export PERL_UNICODE=SAD
159 ### emulate a local::lib-like env
161 # trick cpanm into executing true as shell - we just need the find+unpack
162 run_or_err "Downloading latest stable DBIC from CPAN" \
163 "SHELL=/bin/true cpanm --look DBIx::Class"
165 # move it somewhere as following cpanm will clobber it
166 run_or_err "Moving latest stable DBIC from CPAN to /tmp" "mv ~/.cpanm/latest-build/DBIx-Class-*/lib /tmp/stable_dbic_lib"
168 export PERL5LIB="/tmp/stable_dbic_lib:$PERL5LIB"
170 # perldoc -l <mod> searches $(pwd)/lib in addition to PERL5LIB etc, hence the cd /
171 echo_err "Latest stable DBIC (without deps) locatable via \$PERL5LIB at $(cd / && perldoc -l DBIx::Class)"
174 if [[ "$CLEANTEST" != "true" ]] ; then
175 # using SQLT if will be available
176 # not doing later because we will be running in a subshell
177 export DBICTEST_SQLT_DEPLOY=1
181 # FIXME - work around https://github.com/miyagawa/cpanminus/issues/462
183 perl -p -i -e 's/\blocal\$self->\{notest\}=1;//' $(which cpanm)