From 6ee239e8b4c2d9f14364d71bd02fc12987d75f94 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Fri, 22 Nov 2024 09:46:56 +0530 Subject: [PATCH] fix: auth-react script --- .circleci/setupAndTestWithAuthReact.sh | 22 +++++++++++++++++++ .../setupAndTestWithAuthReactWithDjango.sh | 22 +++++++++++++++++++ .../setupAndTestWithAuthReactWithFlask.sh | 22 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/.circleci/setupAndTestWithAuthReact.sh b/.circleci/setupAndTestWithAuthReact.sh index a90f7e1d..9433229b 100755 --- a/.circleci/setupAndTestWithAuthReact.sh +++ b/.circleci/setupAndTestWithAuthReact.sh @@ -65,6 +65,25 @@ cd ../../../../supertokens-auth-react/ # SKIP_OAUTH=true npm run test-with-non-node +# Exit script from startEndToEnd func. +trap "exit 1" TERM +export EXIT_PID=$$ + +function killServers () { + if [[ "${SERVER_STARTED}" != "true" ]]; then + echo "Kill servers." + lsof -i tcp:8082 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + lsof -i tcp:3031 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + else + echo "Leaving servers running because SERVER_STARTED=true" + fi +} + +trap "killServers" EXIT # Trap to execute on script shutdown + +# Start by killing any servers up on 8082 and 3031 if any. +killServers + mkdir -p ~/test_report/logs mkdir -p ~/test_report/react-logs mkdir -p ~/test_report/screenshots @@ -106,6 +125,9 @@ fi SCREENSHOT_ROOT=~/test_report/screenshots APP_SERVER=$apiPort TEST_MODE=testing npx mocha --bail=$BAIL --require @babel/register --require test/test.mocha.env --timeout 40000 --no-config $SPEC_FILES testPassed=$?; +echo "testPassed exit code: $testPassed" +killServers + if [[ $testPassed -ne 0 ]] then echo "test failed... killing $pid and exiting!" diff --git a/.circleci/setupAndTestWithAuthReactWithDjango.sh b/.circleci/setupAndTestWithAuthReactWithDjango.sh index e1ab5605..8a10f505 100755 --- a/.circleci/setupAndTestWithAuthReactWithDjango.sh +++ b/.circleci/setupAndTestWithAuthReactWithDjango.sh @@ -67,6 +67,25 @@ cd ../../../../supertokens-auth-react/ # SKIP_OAUTH=true npm run test-with-non-node +# Exit script from startEndToEnd func. +trap "exit 1" TERM +export EXIT_PID=$$ + +function killServers () { + if [[ "${SERVER_STARTED}" != "true" ]]; then + echo "Kill servers." + lsof -i tcp:8082 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + lsof -i tcp:3031 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + else + echo "Leaving servers running because SERVER_STARTED=true" + fi +} + +trap "killServers" EXIT # Trap to execute on script shutdown + +# Start by killing any servers up on 8082 and 3031 if any. +killServers + mkdir -p ~/test_report/logs mkdir -p ~/test_report/react-logs mkdir -p ~/test_report/screenshots @@ -108,6 +127,9 @@ fi SCREENSHOT_ROOT=~/test_report/screenshots APP_SERVER=$apiPort TEST_MODE=testing npx mocha --bail=$BAIL --require @babel/register --require test/test.mocha.env --timeout 40000 --no-config $SPEC_FILES testPassed=$?; +echo "testPassed exit code: $testPassed" +killServers + if [[ $testPassed -ne 0 ]] then echo "test failed... killing $pid and exiting!" diff --git a/.circleci/setupAndTestWithAuthReactWithFlask.sh b/.circleci/setupAndTestWithAuthReactWithFlask.sh index 6d666e0d..5e34877c 100755 --- a/.circleci/setupAndTestWithAuthReactWithFlask.sh +++ b/.circleci/setupAndTestWithAuthReactWithFlask.sh @@ -67,6 +67,25 @@ cd ../../../../supertokens-auth-react/ # SKIP_OAUTH=true npm run test-with-non-node +# Exit script from startEndToEnd func. +trap "exit 1" TERM +export EXIT_PID=$$ + +function killServers () { + if [[ "${SERVER_STARTED}" != "true" ]]; then + echo "Kill servers." + lsof -i tcp:8082 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + lsof -i tcp:3031 | grep -m 1 node | awk '{printf $2}' | cut -c 1- | xargs -I {} kill -9 {} > /dev/null 2>&1 + else + echo "Leaving servers running because SERVER_STARTED=true" + fi +} + +trap "killServers" EXIT # Trap to execute on script shutdown + +# Start by killing any servers up on 8082 and 3031 if any. +killServers + mkdir -p ~/test_report/logs mkdir -p ~/test_report/react-logs mkdir -p ~/test_report/screenshots @@ -108,6 +127,9 @@ fi SCREENSHOT_ROOT=~/test_report/screenshots APP_SERVER=$apiPort TEST_MODE=testing npx mocha --bail=$BAIL --require @babel/register --require test/test.mocha.env --timeout 40000 --no-config $SPEC_FILES testPassed=$?; +echo "testPassed exit code: $testPassed" +killServers + if [[ $testPassed -ne 0 ]] then echo "test failed... killing $pid and exiting!"