Skip to content

Commit

Permalink
separate server setup
Browse files Browse the repository at this point in the history
  • Loading branch information
JanneAalto committed Oct 18, 2018
1 parent bfaa63f commit 8d609cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 50 deletions.
32 changes: 7 additions & 25 deletions bin/e2e-test
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,28 @@ PATH="vendor/bin:$PATH"
testport=${E2E_PORT:-"5000"}

if [ -f 'tests/e2e/spec.conf.js' ]; then
jsSpec='tests/e2e/spec.conf.js'
testSpec='tests/e2e/spec.conf.js'
else
jsSpec='e2e/spec.conf.js'
testSpec='e2e/spec.conf.js'
fi

testspec=${E2E_SPEC:-"$jsSpec"}

if [ -d 'bedrock-on-heroku' ]; then
config='config/app_nginx.conf.php'
path='bedrock-on-heroku/web'
elif [ -d 'web' ]; then
config='config/heroku/nginx.conf'
path='web'
elif [ -d 'public' ]; then
config='nginx.conf'
path='public'
else
config='config/heroku/nginx.conf'
path='web'
fi

testproc=${E2E_PROC:-"heroku-php-nginx -C $config $path"}
testspec=${E2E_SPEC:-"$testSpec"}

hash npx 2>/dev/null || { echo >&2 "Unable to find npx in PATH."; exit 1; }
hash chromedriver 2>/dev/null || { echo >&2 "Unable to find chromedriver in PATH."; exit 1; }
[[ -f $testspec ]] || { echo >&2 "No e2e tests defined: $testspec not found."; exit 1; }

PORT=$testport $testproc >/tmp/$$-http-log.txt 2>&1 &
proc_pid=$!

chromedriver --port=9515 >/dev/null 2>&1 &
chromedriver_pid=$!

npx wait-on -l "tcp:$testport" "tcp:9515"
npx wait-on -l "tcp:9515"
npx protractor "$testspec" "--baseUrl" "http://localhost:$testport/"
protractor_exit=$?

echo "--- http server log ---"
cat /tmp/$$-http-log.txt
cat /tmp/http-log.txt
echo "--- http server log ---"
> /tmp/http-log.txt

kill $chromedriver_pid $proc_pid
kill $chromedriver_pid
exit $protractor_exit
29 changes: 4 additions & 25 deletions bin/pa11y-test
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@
PATH="vendor/bin:$PATH"
testport=${E2E_PORT:-"5000"}


if [ -d 'bedrock-on-heroku' ]; then
config='config/app_nginx.conf.php'
path='bedrock-on-heroku/web'
elif [ -d 'web' ]; then
config='config/heroku/nginx.conf'
path='web'
elif [ -d 'public' ]; then
config='nginx.conf'
path='public'
else
config='config/heroku/nginx.conf'
path='web'
fi

testproc=${E2E_PROC:-"heroku-php-nginx -C $config $path"}


if [ -f 'tests/pa11y/pa11y.conf.json' ]; then
testSpec='tests/pa11y/pa11y.conf.json'
else
Expand All @@ -33,20 +15,17 @@ hash npx 2>/dev/null || { echo >&2 "Unable to find npx in PATH."; exit 1; }
hash chromedriver 2>/dev/null || { echo >&2 "Unable to find chromedriver in PATH."; exit 1; }
[[ -f $testspec ]] || { echo >&2 "No pa11y tests defined: $testspec not found."; exit 1; }

PORT=$testport $testproc >/tmp/$$-http-log.txt 2>&1 &
proc_pid=$!


chromedriver --port=9515 >/dev/null 2>&1 &
chromedriver_pid=$!

npx wait-on -l "tcp:$testport" "tcp:9515"
npx wait-on -l "tcp:9515"
npx pa11y-ci --config "$testspec"
pa11y_exit=$?

echo "--- http server log ---"
cat /tmp/$$-http-log.txt
cat /tmp/http-log.txt
echo "--- http server log ---"
> /tmp/http-log.txt

kill $chromedriver_pid $proc_pid
kill $chromedriver_pid
exit $pa11y_exit
22 changes: 22 additions & 0 deletions bin/php-nginx-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

PATH="vendor/bin:$PATH"

if [ -d 'bedrock-on-heroku' ]; then
config='config/app_nginx.conf.php'
path='bedrock-on-heroku/web'
elif [ -d 'web' ]; then
config='config/heroku/nginx.conf'
path='web'
elif [ -d 'public' ]; then
config='nginx.conf'
path='public'
else
config='config/heroku/nginx.conf'
path='web'
fi

testproc=${E2E_PROC:-"heroku-php-nginx -C $config $path"}
testport=${E2E_PORT:-"5000"}

PORT=$testport $testproc >/tmp/http-log.txt 2>&1 & sleep 5
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"license": "MIT",
"bin": [
"bin/migratedb",
"bin/php-nginx-setup",
"bin/e2e-test",
"bin/platform-test",
"bin/pa11y-test"
Expand Down

0 comments on commit 8d609cf

Please sign in to comment.