brew custom perls for travis
[gitmo/Moo.git] / maint / travis-perlbrew
diff --git a/maint/travis-perlbrew b/maint/travis-perlbrew
new file mode 100644 (file)
index 0000000..f3a4a6c
--- /dev/null
@@ -0,0 +1,13 @@
+BREWVER=${TRAVIS_PERL_VERSION/_*/}
+BREWOPTS=
+[[ "${TRAVIS_PERL_VERSION}_" =~ '_thr_' ]] && BREWOPTS="$BREWOPTS -Duseithreads"
+
+if ! perlbrew use | grep -q "Currently using $TRAVIS_PERL_VERSION"; then
+  perlbrew install --as $TRAVIS_PERL_VERSION --notest --noman --verbose $BREWOPTS -j 2 $BREWVER
+  perlbrew use $TRAVIS_PERL_VERSION
+  if ! perlbrew use | grep -q "Currently using $TRAVIS_PERL_VERSION"; then
+    echo "Unable to switch to $TRAVIS_PERL_VERSION - compilation failed...?" 1>&2
+    exit 1
+  fi
+fi
+perlbrew install-cpanm -f