sudo: false
dist: xenial
language: perl
perl:
    # ~stretch
    - "5.24-shrplib"
    - "system-perl"
env:
    - CC=clang UNITTESTS=false
    - CC=gcc   UNITTESTS=false
    - CC=clang UNITTESTS=true
matrix:
    exclude:
        - env: CC=clang UNITTESTS=true
          perl: "system-perl"
    allow_failures:
        - env: CC=clang UNITTESTS=true

addons:
    apt:
        packages:
            - libperl-dev
            - elinks
            - libgcrypt11-dev
            - libotr5-dev

before_install:
    - perl -V
    - pushd ~
    - curl -sSLf https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip | funzip > bin/ninja
    - chmod +x bin/ninja
    - curl -sSLf https://github.com/mesonbuild/meson/releases/download/0.51.1/meson-0.51.1.tar.gz | tar xz
    - ( cd bin ; ln -s ../meson-*/meson.py meson )
    - curl -sSLf https://github.com/irssi-import/glib-travis-build/releases/download/2.58.3/travis-xenial-glib-2.58.3.tar.xz | tar xJ
    - export PKG_CONFIG_PATH=$HOME/glib-build/lib/x86_64-linux-gnu/pkgconfig
    - export LD_LIBRARY_PATH=$HOME/glib-build/lib/x86_64-linux-gnu
    - popd

install:
    - meson Build -Dwith-proxy=yes -Dwith-bot=yes -Dwith-perl=yes -Dwith-otr=yes --prefix=$HOME/irssi-build
    - ninja -C Build
    - ninja -C Build install

before_script:
    - pushd ~
    - mkdir irssi-test
    - echo echo automated irssi launch test > irssi-test/startup;
      echo ^set settings_autosave off >> irssi-test/startup;
      echo ^set -clear log_close_string >> irssi-test/startup;
      echo ^set -clear log_day_changed >> irssi-test/startup;
      echo ^set -clear log_open_string >> irssi-test/startup;
      echo ^set log_timestamp '* ' >> irssi-test/startup;
      echo ^window log on >> irssi-test/startup
    - echo load perl >> irssi-test/startup
    - echo load proxy >> irssi-test/startup
    - echo ^quit >> irssi-test/startup

script:
    - irssi-build/bin/irssi --home irssi-test
    - popd
    - if $UNITTESTS; then ninja -C Build test; fi

after_script:
    - cat ~/irc.log.*
    - find -name testlog.txt -exec sed -i -e '/Inherited environment:.* TRAVIS/d' {} + -exec cat {} +
