11#! /usr/bin/env bash
2- set -ex
2+ set -e
33
44this_script=$( basename " $0 " )
55
66# Install some tools
77echo " *** [${this_script} ] Installing some OS packages"
8- apt-get update
9- apt-get install -y git wget zip
8+ apt-get update > /dev/null 2>&1
9+ apt-get install -y git wget zip > /dev/null 2>&1
1010
1111# The composer installation steps via https://getcomposer.org/download/
1212# and https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
@@ -28,7 +28,7 @@ echo "*** [${this_script}] Removing composer-setup.php"
2828php -r " unlink('composer-setup.php');"
2929
3030echo " *** [${this_script} ] Changing to binding source directory"
31- pushd /source
31+ pushd /php- source
3232
3333# TODO: Review if we should be using a compose.lock file instead.
3434echo " *** [${this_script} ] Running composer update"
@@ -37,15 +37,46 @@ composer update
3737echo " *** [${this_script} ] Running composer install"
3838composer install --prefer-source --no-interaction
3939
40- echo " *** [${this_script} ] Running phpspec"
41- bin/phpspec run --config=phpspec.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
40+ # Install Xdebug coverage tool
41+ version=$( php -v | awk ' match($0, /PHP [78]\.[0-4]/) { print substr($0, RSTART, RLENGTH) } ' | awk ' {print $2}' )
42+ echo " *** [${this_script} ] PHP version: $version "
43+ if [ " ${version} " == " 8.1" ]; then
44+ # Installation according to https://xdebug.org/docs/install#source
45+ echo " *** [${this_script} ] Installing Xdebug coverage tool"
46+ cd /
47+ git clone https://github.com/xdebug/xdebug.git
48+ cd xdebug
49+ git checkout 3.1.5 > /dev/null 2>&1
50+ phpize
51+ ./configure --enable-xdebug > /dev/null 2>&1
52+ make > /dev/null 2>&1
53+ make install > /dev/null 2>&1
54+ echo " zend_extension=xdebug" > /usr/local/etc/php/conf.d/99-xdebug.ini
55+ export XDEBUG_MODE=coverage
56+ cd /php-source
57+ echo " *** [${this_script} ] Running phpspec"
58+ bin/phpspec run --config=phpspec.coverage.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
59+ else
60+ echo " *** [${this_script} ] Skipping test coverage generation for this version"
61+ echo " *** [${this_script} ] Running phpspec"
62+ bin/phpspec run --config=phpspec.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
63+ fi
4264
4365echo " *** [${this_script} ] Running examples"
4466pushd examples
4567for example in $( ls * .php) ; do
46- echo " *** [${this_script} ] Running ${example} "
47- php ${example} --key ${ROSETTE_API_KEY}
48- # TODO: Capture output in a file and only print it for errors.
68+ echo " *** [${this_script} ] Running ${example} with PHP ${version} "
69+ php ${example} --key ${ROSETTE_API_KEY} > " ${example} -output.txt" 2>&1
70+ # Disable error mode for grep
71+ set +e
72+ if grep -q Exception " ${example} -output.txt" ; then
73+ echo " *** [${this_script} ] ${example} failed!"
74+ cat " ${example} -output.txt"
75+ rm -f " ${example} -output.txt"
76+ exit 1
77+ fi
78+ set -e
79+ rm -f " ${example} -output.txt"
4980done
5081
5182echo " *** [${this_script} ] Finished!"
0 commit comments