language: python

matrix:
  include:
    - python: 3.3
      dist: trusty
    - python: 3.4
      dist: trusty
    - python: 3.5
      dist: trusty
    - python: 3.6
      dist: trusty
    - python: 3.7
      dist: xenial
      sudo: true
    - python: 3.8
      dist: xenial
      sudo: true
    - python: 3.9-dev
      dist: xenial
      sudo: true
    - python: pypy3
      dist: trusty

install:
  # Install a recent build of pypy3.
  # https://github.com/frol/flask-restplus-server-example/blob/master/.travis.yml
  - |
      if [ "$TRAVIS_PYTHON_VERSION" = "pypy3" ]; then
        PYPY3_VERSION="pypy3.5-7.0.0"
        PYENV_ROOT="$HOME/.pyenv"
        if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
          pushd "$PYENV_ROOT" && git pull && popd
        else
          rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
        fi
        "$PYENV_ROOT/bin/pyenv" install --skip-existing "$PYPY3_VERSION"
        virtualenv --version
        virtualenv --python="$PYENV_ROOT/versions/$PYPY3_VERSION/bin/python" --no-setuptools --no-pip "$HOME/virtualenvs/$PYPY3_VERSION"
        source "$HOME/virtualenvs/$PYPY3_VERSION/bin/activate"
      fi
  - if [ "$TRAVIS_PYTHON_VERSION" = "3.5" ]; then pip3 install codecov; fi
  - if [ "$TRAVIS_PYTHON_VERSION" = "3.7" ]; then pip3 install unicodedata2==12.0.0; fi
script:
  - python --version
  - python -c "import unicodedata; print(unicodedata.unidata_version)"
  - python -m unittest discover
  - python -m doctest README.rst
  - if [ "$TRAVIS_PYTHON_VERSION" = "3.5" ]; then coverage run --source precis_i18n -m unittest test/test_precis.py test/test_codepointset.py test/test_codec.py test/test_factory.py; fi

after_success:
  - if [ "$TRAVIS_PYTHON_VERSION" = "3.5" ]; then codecov; fi

