Skip to content

Commit f89e919

Browse files
committed
WIP start of new coverage-report script.
1 parent 80c6918 commit f89e919

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"codesniffer-run",
2323
"composer-install",
2424
"coverage-ensure",
25+
"coverage-report",
2526
"db-backup",
2627
"db-credentials",
2728
"db-login",

coverage-report

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
#---------------------------------------------------------------------
4+
usage ()
5+
{
6+
cat <<EOT
7+
8+
${0##*/}
9+
Convenience wrapper to execute phpunit test suite, generate
10+
html coverage and open it in your browser (if you're on a Mac.)
11+
12+
Should be run from the project root folder.
13+
14+
Usage:
15+
bin/${0##*/}
16+
17+
18+
EOT
19+
20+
exit ${1:-0} # Exit with code 0 unless an arg is passed to the method.
21+
}
22+
if [ "$1" = '-h' ]; then
23+
usage
24+
fi
25+
26+
27+
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
28+
COVERAGE_PATH="tmp/coverage/html/"
29+
30+
31+
# Launch the coverage in a browser if requested and we're on the host.
32+
if command -v 'open' >/dev/null 2>&1; then
33+
bin/vagrant-exec "vendor/bin/phpunit --coverage-html="$COVERAGE_PATH""
34+
open "${COVERAGE_PATH}index.html"
35+
else
36+
cd "$DIR"
37+
bin/phpunit --coverage-html="$COVERAGE_PATH"
38+
echo ""
39+
echo "## Run 'open ${COVERAGE_PATH}index.html'"
40+
echo "## from your host to view coverage reports in a browser."
41+
echo ""
42+
fi

0 commit comments

Comments
 (0)