#!/usr/bin/env bash
cd "$(dirname "$0")"
. "./.common.sh"
cd ..
PATH="$PWD/sandbox/composer/bin:$PATH"
if ! chkcmd 'peridot'; then
echo ' error: "peridot" command not found.'
echo ' Execute "./support/init" first.'
exit 1
fi
coverage_index="$PWD/sandbox/code-coverage-report/index.html"
## It's is not created automatically.
mkdir -p "$(dirname "$coverage_index")"
reporter=html-code-coverage
if test $# -eq 1; then
reporter=$1
fi
peridot_arguments="-c ./support/peridot.php -r $reporter -g *.php ./specs/"
if php -m | grep -i 'xdebug' > /dev/null; then
echo ' info: using Xdebug.'
set -- $peridot_arguments
peridot "$@"
elif chkcmd 'phpdbg'; then
echo ' info: using phpdbg.'
set -- $peridot_arguments
phpdbg -e -rr "$(which peridot)" "$@"
else
echo ' error: no profiling tool found.'
exit 1
fi
if test -f "$coverage_index" && chkcmd 'open'; then
open "$coverage_index"
fi
|