bye bye Travis
[plcapi.git] / tests / ci / setup / setup_code_coverage.sh
1 #!/bin/sh
2
3 # @todo add 'query' action
4 # @todo avoid reloading php-fpm if config did not change
5
6 # Note: we have php set up either via Ubuntu packages (PHP_VERSION=default) or Sury packages.
7 #       xdebug comes either at version 2 or 3
8
9 set -e
10
11 enable_cc() {
12     if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
13     sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"
14     if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
15     sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"
16
17     sudo service php-fpm restart
18 }
19
20 disable_cc() {
21     if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
22     if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
23
24     sudo service php-fpm restart
25 }
26
27 case "$1" in
28    enable | on)
29        enable_cc
30        ;;
31    disable | off)
32        disable_cc
33        ;;
34    *)
35        echo "ERROR: unknown action '${1}', please use 'enable' or 'disable'" >&2
36        exit 1
37        ;;
38 esac