Skip to content

Commit

Permalink
Merge pull request #66 from stof/improve_test_runner
Browse files Browse the repository at this point in the history
Ensure that the cleanup of process runs on test failure
  • Loading branch information
jcalderonzumba committed Nov 17, 2016
2 parents f0d26b1 + 158d56b commit 9f01c7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Expand Up @@ -24,6 +24,8 @@ env:
- MINK_PHP_BIN=~/.phpenv/versions/5.6/bin/php
# Force the mink test server to bin on IPv4, as PhantomJS resolves localhost as IPv4 while PHP seems to prefer resolving it as IPv6 on Travis
- MINK_HOST=127.0.0.1:8002
# Avoid restarting the browser api at the end of tests (see bin/run_tests.sh)
- MINK_STOP_BROWSER=1

cache:
directories:
Expand All @@ -41,7 +43,3 @@ before_script:

script:
- bin/run-tests.sh

after_script:
- ps axo pid,command | grep phantomjs | grep -v grep | awk '{print $1}' | xargs -I {} kill {}
- ps axo pid,command | grep php | grep -v grep | awk '{print $1}' | xargs -I {} kill {}
13 changes: 10 additions & 3 deletions bin/run-tests.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

start_browser_api(){
Expand All @@ -24,11 +24,18 @@ start_local_browser(){
sleep 2
}

function finish() {
stop_services
if [ -z "$MINK_STOP_BROWSER" ]; then
start_browser_api
fi
}

trap finish EXIT

mkdir -p /tmp/jcalderonzumba/phantomjs
stop_services || true
start_browser_api
start_local_browser
cd ${CURRENT_DIR}
${CURRENT_DIR}/bin/phpunit --configuration integration_tests.xml
stop_services
start_browser_api

0 comments on commit 9f01c7e

Please sign in to comment.