Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup server before running tests #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor
/node_modules
/package-lock.json
#/package-lock.json
/yarn.lock
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
Loading