Skip to content

Commit b10bec9

Browse files
committed
Changed logic in seleniumbender script to reduce repeated code.
Moved ROOTDIR variable to env_vars.sh .
1 parent a6cfebf commit b10bec9

File tree

2 files changed

+49
-41
lines changed

2 files changed

+49
-41
lines changed

bin/env_vars.sh.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ export DISQUS_API_PUBLIC=""
1313
export DISQUS_SSO_ID=""
1414
export DISQUS_SSO_USERNAME=""
1515
export DISQUS_SSO_EMAIL=""
16+
17+
export EMAIL=""
18+
19+
export ROOTDIR="/path/to/seleniumTests"

bin/seleniumbender

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
#!/bin/bash
22

3-
export CAPABILITIES='capabilities_firefox.yaml'
4-
53
source ./env_vars.sh
64

7-
ROOTDIR="/path/to/seleniumTests"
8-
95
if [ $# -lt 1 ]; then
106
echo "Please provide an argument or run -h(--help) option"
117
exit 1
128
fi
139

1410
app_name="$0"
15-
common=0
16-
libraries=0
11+
12+
target=0
1713
examples=0
14+
libraries=0
1815
sketches=0
19-
staging=0
16+
common=0
2017
noplugin=0
2118
walkthrough=0
22-
target=0
19+
staging=0
2320

2421
while true; do
2522
case "$1" in
@@ -29,29 +26,32 @@ while true; do
2926
" libraries - Visits all the libraries and examples at libraries view\n" \
3027
" examples - Compiles all the examples at libraries view\n" \
3128
" sketches - Compiles the examples of user cb_compile_tester\n" \
29+
" target - Compiles the examples of given libraries as comma seperated list\n" \
30+
" noplugin - Runs tests that do not need plugin installed\n" \
31+
" walkthrough - Runs tests for walkthrough\n" \
32+
" staging - Runs tests in staging\n" \
3233
" help - Display this help and exit"
3334
exit 0
3435
;;
35-
common) common=1
36-
;;
37-
libraries) libraries=1
38-
;;
39-
examples) examples=1
40-
;;
41-
target) compile=1
36+
target) target=1
4237
shift
43-
target=1
4438
TARGETS=$@
4539
break
4640
;;
41+
examples) examples=1
42+
;;
43+
libraries) libraries=1
44+
;;
4745
sketches) sketches=1
4846
;;
49-
staging) staging=1
47+
common) common=1
5048
;;
5149
noplugin) noplugin=1
5250
;;
5351
walkthrough) walkthrough=1
5452
;;
53+
staging) staging=1
54+
;;
5555
-*) echo -e "error: unknown argument: ${1}.\nRun ${app_name} -h."
5656
exit 1
5757
;;
@@ -64,19 +64,16 @@ done
6464
cd ..
6565

6666
URL="https://codebender.cc"
67-
URL_STAGING="https://staging.codebender.cc"
6867
SOURCE="codebender_cc"
6968

7069
email_date=$(date +"%Y-%m-%d %H:%M:%S")
7170

72-
if [ "${common}" -eq 1 ]; then
73-
IDENTIFIER="common"
74-
tox tests/common -- --url=${URL} --source=${SOURCE} --plugin
75-
RETVAL=$?
76-
if [ "${RETVAL}" -eq 1 ]; then
77-
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" ${EMAIL} <<< 'Something went wrong with common tests. Please check the logs.'
78-
fi
79-
exit ${RETVAL}
71+
RETVAL=0
72+
NO_LOGS=0
73+
74+
if [ "${target}" -eq 1 ]; then
75+
IDENTIFIER="test_target_libraries"
76+
tox tests/target_libraries -- --url=${URL} --source=${SOURCE} -F --plugin --libraries=${TARGETS}
8077
elif [ "${examples}" -eq 1 ]; then
8178
IDENTIFIER="libraries_test"
8279
tox tests/libraries -- --url=${URL} --source=${SOURCE} -F --plugin
@@ -86,18 +83,16 @@ elif [ "${libraries}" -eq 1 ]; then
8683
elif [ "${sketches}" -eq 1 ]; then
8784
IDENTIFIER="cb_compile_tester"
8885
tox tests/compile_tester -- --url=${URL} --source=${SOURCE} -F --plugin
89-
elif [ "${staging}" -eq 1 ]; then
90-
IDENTIFIER="cb_compile_tester_staging"
91-
tox tests/compile_tester -- --url=${URL_STAGING} --source=${SOURCE} -F --plugin
92-
exit $?
86+
elif [ "${common}" -eq 1 ]; then
87+
IDENTIFIER="common"
88+
tox tests/common -- --url=${URL} --source=${SOURCE} --plugin
89+
RETVAL=$?
90+
NO_LOGS=1
9391
elif [ "${noplugin}" -eq 1 ]; then
9492
IDENTIFIER="noplugin"
9593
tox tests/noplugin -- --url=${URL} --source=${SOURCE}
9694
RETVAL=$?
97-
if [ "${RETVAL}" -eq 1 ]; then
98-
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" ${EMAIL} <<< 'Something went wrong with noplugin tests. Please check the logs.'
99-
fi
100-
exit ${RETVAL}
95+
NO_LOGS=1
10196
elif [ "${walkthrough}" -eq 1 ]; then
10297
IDENTIFIER="walkthrough"
10398
RETVALS=()
@@ -114,22 +109,31 @@ elif [ "${walkthrough}" -eq 1 ]; then
114109
tox tests/walkthrough -- --url=${URL} --source=${SOURCE} --plugin
115110
RETVALS+=($?)
116111

117-
RETVAL=0
118112
for i in "${RETVALS[@]}"
119113
do
120114
if [ ${i} -ne 0 ]; then
121115
RETVAL=${i}
122116
fi
123117
done
124-
if [ "${RETVAL}" -ne 0 ]; then
125-
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" ${EMAIL} <<< 'Something went wrong with noplugin tests. Please check the logs.'
126-
fi
118+
NO_LOGS=1
119+
elif [ "${staging}" -eq 1 ]; then
120+
IDENTIFIER="cb_compile_tester_staging"
121+
URL="https://staging.codebender.cc"
122+
tox tests/compile_tester -- --url=${URL} --source=${SOURCE} -F --plugin
123+
# No need to send email for tests in staging
124+
exit $?
125+
fi
126+
127+
# email notification without attaching any logs
128+
if [ ${RETVAL} -ne 0 ]; then
129+
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" ${EMAIL} <<< "Something went wrong with ${IDENTIFIER} tests. Please check the logs."
130+
fi
131+
132+
if [ ${NO_LOGS} -eq 1 ]; then
127133
exit ${RETVAL}
128-
elif [ "${target}" -eq 1 ]; then
129-
IDENTIFIER="test_target_libraries"
130-
tox tests/target_libraries -- --url=${URL} --source=${SOURCE} -F --plugin --libraries=${TARGETS}
131134
fi
132135

136+
# email notification with attaching the produced reports
133137
DATE=$(date +"%Y-%m-%d") # Get the current date
134138
LOGS="${ROOTDIR}/logs"
135139
REPORTS="${ROOTDIR}/reports"

0 commit comments

Comments
 (0)