machine:
  environment:
    PATH: ~/.plenv/bin:~/.plenv/shims:$PATH
  timezone:
    Asia/Tokyo

dependencies:
  cache_directories:
    - ~/.plenv
  pre:
    - |
      if [ ! -e ~/.plenv/bin/plenv ]; then
        git clone --depth=1 https://github.com/tokuhirom/plenv.git ~/.plenv
        eval "$(plenv init -)"
        git clone --depth=1 https://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/

        for version in 5.24.0 5.22.2 5.16.3 5.12.5 5.10.1
        do
          FLAGS=""
          if [ $version == "5.24.0" ]; then
            FLAGS="-Dusethreads"
          fi
          plenv install $version $FLAGS
          plenv global $version
          plenv install-cpanm
        done
      fi

test:
  override:
    - plenv global 5.24.0
    - cpanm --installdeps -n .
    - perl Build.PL && ./Build && ./Build test
    - plenv global 5.22.2
    - cpanm --installdeps -n .
    - perl Build.PL && ./Build && ./Build test
    - plenv global 5.16.3
    - cpanm --installdeps -n .
    - perl Build.PL && ./Build && ./Build test
    - plenv global 5.12.5
    - cpanm --installdeps -n .
    - perl Build.PL && ./Build && ./Build test
    - plenv global 5.10.1
    - cpanm --installdeps -n .
    - perl Build.PL && ./Build && ./Build test
