Fix tests failing due to unspecified resultset retrieval order
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 30_before_script.bash
CommitLineData
b58ecb01 1#!/bin/bash
2
3source maint/travis-ci_scripts/common.bash
4if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
eed5492f 6# poison the environment - basically look through lib, find all mentioned
7# ENVvars and set them to true and see if anything explodes
8if [[ "$POISON_ENV" = "true" ]] ; then
9 for var in $(grep -P '\$ENV\{' -r lib/ | grep -oP 'DBIC_\w+' | sort -u | grep -v DBIC_TRACE) ; do
10 export $var=1
11 done
fb88ca2c 12
13 export DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER=1
eed5492f 14fi
15
992a24f6 16# try Schwern's latest offering on a stock perl and a threaded blead
17# can't do this with CLEANTEST=true yet because a lot of our deps fail
18# tests left and right under T::B 1.5
19if [[ "$CLEANTEST" != "true" ]] && ( [[ -z "$BREWVER" ]] || [[ "$BREWVER" = "blead" ]] ) ; then
20 # FIXME - there got to be a way to ask metacpan for this dynamically
21 TEST_BUILDER_BETA_CPAN_TARBALL="M/MS/MSCHWERN/Test-Simple-1.005000_005.tar.gz"
22fi
23
24
b58ecb01 25if [[ "$CLEANTEST" = "true" ]]; then
26 # get the last inc/ off cpan - we will get rid of MI
27 # soon enough, but till then this will do
28 # the point is to have a *really* clean perl (the ones
29 # we build are guaranteed to be clean, without side
30 # effects from travis preinstalls)
31
32 # trick cpanm into executing true as shell - we just need the find+unpack
33 run_or_err "Downloading DBIC inc/ from CPAN" \
34 "SHELL=/bin/true cpanm --look DBIx::Class"
35
36 mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
37
992a24f6 38 # this should be installable anywhere, regardles of prereqs
39 if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
40 run_or_err "Pre-installing dev-beta of Test::Builder ($TEST_BUILDER_BETA_CPAN_TARBALL)" \
41 "cpan $TEST_BUILDER_BETA_CPAN_TARBALL"
42 fi
43
b58ecb01 44 # older perls do not have a CPAN which understands configure_requires
45 # properly and what is worse a `cpan Foo` run exits with 0 even if some
46 # modules failed to install
47 # The first CPAN which is somewhat sane is around 1.94_56 (perl 5.12)
48 # The problem is that the first sane version also brings a *lot* of
49 # deps with it, notably things like YAML and HTTP::Tiny
50 # The goal of CLEANTEST is to have as little extra stuff installed as
51 # possible, mainly to catch "but X is perl core" mistakes
52 # So instead we still use our stock (possibly old) CPAN, and add some
53 # handholding
54 CPAN_is_sane || \
55 run_or_err "Pre-installing ExtUtils::MakeMaker and Module::Build" \
56 "cpan ExtUtils::MakeMaker Module::Build"
57
58 if ! perl -MModule::Build -e 1 &> /dev/null ; then
59 echo_err -e "Module::Build installation failed\n$LASTOUT"
60 exit 1
61 fi
62
63 # DBI has by far the longest test runtime - run less tests
64 # FIXME horrible horrible hack, need to implement in DBI itself
65 run_or_err "Downloading latest DBI distdir from CPAN" \
66 "SHELL=/bin/true cpanm --look DBI"
67 cd ~/.cpanm/latest-build/DBI-*/
68 perl -p -i -e 's/(create_.+?_tests) => 1/$1 => 0/' Makefile.PL
69 run_or_err "Pre-installing DBI, but running less tests" "perl Makefile.PL && make && make test && make install"
70 cd - &>/dev/null
71
72else
73 # we will be running all dbic tests - preinstall lots of stuff, run basic tests
74 # using SQLT and set up whatever databases necessary
75 export DBICTEST_SQLT_DEPLOY=1
76
77 # do the preinstall in several passes to minimize amount of cross-deps installing
78 # multiple times, and to avoid module re-architecture breaking another install
91d48c58 79 # (e.g. once Carp is upgraded there's no more Carp::Heavy,
80 # while a File::Path upgrade may cause a parallel EUMM run to fail)
b58ecb01 81 #
82 parallel_installdeps_notest ExtUtils::MakeMaker
91d48c58 83 parallel_installdeps_notest File::Path
b58ecb01 84 parallel_installdeps_notest Carp
435f9f82 85 parallel_installdeps_notest Module::Build ExtUtils::Depends
86 parallel_installdeps_notest Module::Runtime File::Spec Data::Dumper
5f7ad019 87 parallel_installdeps_notest Test::Exception Encode::Locale Test::Fatal
88 parallel_installdeps_notest Test::Warn bareword::filehandles B::Hooks::EndOfScope Test::Differences HTTP::Status
f5616614 89 parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Name MRO::Compat Class::XSAccessor URI::Escape HTML::Entities
2cf93a3d 90 parallel_installdeps_notest YAML LWP Class::Trigger JSON::XS DBI DateTime::Format::Builder Class::Accessor::Grouped Package::Variant
91 parallel_installdeps_notest Moose Module::Install JSON SQL::Translator
b58ecb01 92
f5616614 93 if [[ -n "DBICTEST_FIREBIRD_DSN" ]] ; then
b58ecb01 94 # the official version is full of 5.10-isms, but works perfectly fine on 5.8
95 # pull in our patched copy
96 run_or_err "Fetching patched DBD::Firebird" \
97 "git clone https://github.com/dbsrgits/perl-dbd-firebird-5.8.git ~/dbd-firebird"
98
99 # the official version is very much outdated and does not compile on 5.14+
100 # use this rather updated source tree (needs to go to PAUSE):
101 # https://github.com/pilcrow/perl-dbd-interbase
102 run_or_err "Fetching patched DBD::InterBase" \
103 "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
104
105 parallel_installdeps_notest ~/dbd-interbase/ ~/dbd-firebird/
106 fi
107
108fi
109
110# generate the makefile which will have different deps depending on
111# the runmode and envvars set above
112run_or_err "Configure on current branch" "perl Makefile.PL"
113
114# install (remaining) dependencies, sometimes with a gentle push
115if [[ "$CLEANTEST" = "true" ]]; then
116 # we may need to prepend some stuff to that list
117 HARD_DEPS="$(echo $(make listdeps))"
118
119 # this is a fucked CPAN - won't understand configure_requires of
120 # various pieces we may run into
121 CPAN_is_sane || HARD_DEPS="ExtUtils::Depends B::Hooks::OP::Check $HARD_DEPS"
122
123##### TEMPORARY WORKAROUNDS
124
71dd2ecc 125 # The unicode-in-yaml bug on older cpan clients
126 # FIXME there got to be a saner way to fix this...
b58ecb01 127 perl -M5.008008 -e 1 &> /dev/null || \
71dd2ecc 128 run_or_err "Installing multidimensional and bareword::filehandles via cpanm" \
129 "cpanm multidimensional bareword::filehandles"
b58ecb01 130
131 # work around Params::Validate not having a Makefile.PL so really old
132 # toolchains can not figure out what the prereqs are ;(
133 # Need to do more research before filing a bug requesting Makefile inclusion
134 perl -M5.008008 -e 1 &> /dev/null || \
135 HARD_DEPS="$(extract_prereqs Params::Validate) $HARD_DEPS"
136
137##### END TEMPORARY WORKAROUNDS
138
5cbe5b12 139 run_or_err "Installing/testing dependencies (may take up to 3 minutes): $HARD_DEPS" "cpan $HARD_DEPS"
b58ecb01 140
141 # this is a fucked CPAN - save the log as we may need it
142 CPAN_is_sane || INSTALLDEPS_OUT="$LASTOUT"
143
144else
145 # listalldeps is deliberate - will upgrade everything it can find
146 parallel_installdeps_notest $(make listalldeps)
992a24f6 147
148 if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
149 parallel_installdeps_notest $TEST_BUILDER_BETA_CPAN_TARBALL
150 fi
b58ecb01 151fi
152
153echo_err "$(tstamp) Dependency configuration finished"
154# this will display list of available versions
155perl Makefile.PL
156
157# make sure we got everything we need
158if [[ -n "$(make listdeps)" ]] ; then
159 echo_err "$(tstamp) Not all deps installed - something went wrong :("
160 sleep 1 # without this the echo below confuses the console listener >.<
161 CPAN_is_sane || echo_err -e "Outdated CPAN.pm used - full logs follows\n$INSTALLDEPS_OUT\n\nSearch for 'NOT OK' in the text above\n\nDeps still missing:"
162 sleep 3 # without this the above echo confuses the console listener >.<
163 make listdeps
164 exit 1
165fi
166
167# announce what are we running
168echo_err "
169===================== DEPENDENCY CONFIGURATION COMPLETE =====================
170$(tstamp) Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
171
172= CPUinfo
173$(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
174
175= Meminfo
176$(free -m -t)
177
178= Environment
179$(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
180
181= Perl in use
182$(perl -V)
183============================================================================="