forked from CollaboraOnline/online
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_parallel.sh
executable file
·147 lines (133 loc) · 5.11 KB
/
run_parallel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -z "${NODE_PATH}" ]; then
BUILDDIR=${DIR}
else
BUILDDIR=$(dirname ${NODE_PATH})
fi
CYPRESS_BINARY="${BUILDDIR}/node_modules/cypress/bin/cypress"
DESKTOP_TEST_FOLDER="${DIR}/integration_tests/desktop/"
MOBILE_TEST_FOLDER="${DIR}/integration_tests/mobile/"
MULTIUSER_TEST_FOLDER="${DIR}/integration_tests/multiuser/"
ERROR_LOG="${BUILDDIR}/workdir/error.log"
print_help ()
{
echo "Usage: run_parallel.sh --spec <name_spec.js> OPTIONS"
echo "Runs a specified cypress test"
echo ""
echo " --spec <file> The test file we need to run"
echo " --log-file <file> Log output to this test"
echo " --config <string> Configure options passed to cypress"
echo " --env <string> Cypress own environment variables"
echo " --type <string> Type of the test (e.g. mobile, desktop)"
echo " --browser <file> Path to the browser binary"
echo " --second-chance Enable second chance"
exit 1
}
TEST_FILE=
TEST_LOG=
TEST_CONFIG=
TEST_CONFIG_FILE=
TEST_ENV=
TEST_TYPE=
BROWSER=
SECOND_CHANCE=false
while test $# -gt 0; do
case $1 in
--spec) TEST_FILE=$2; shift;;
--log-file) TEST_LOG=$2; shift;;
--config-file) TEST_CONFIG_FILE=$2; shift;;
--config) TEST_CONFIG=$2; shift;;
--env) TEST_ENV=$2; shift;;
--type) TEST_TYPE=$2; shift;;
--browser) BROWSER=$2; shift;;
--help) print_help ;;
-*) ;; # ignore
esac
shift
done
TEST_ERROR="${TEST_LOG}.error"
TEST_FILE_PATH=
if [ "${TEST_TYPE}" = "desktop" -o "${TEST_TYPE}" = "interfer-desktop" ]; then
TEST_FILE_PATH=${DESKTOP_TEST_FOLDER}${TEST_FILE};
elif [ "${TEST_TYPE}" = "mobile" -o "${TEST_TYPE}" = "interfer-mobile" ]; then
TEST_FILE_PATH=${MOBILE_TEST_FOLDER}${TEST_FILE};
elif [ "${TEST_TYPE}" = "multi-user" ]; then
TEST_FILE_PATH=${MULTIUSER_TEST_FOLDER}${TEST_FILE};
elif [ "${TEST_TYPE}" = "interfer" ]; then
TEST_FILE_PATH="${DIR}/integration_tests/common/"${TEST_FILE};
fi
RUN_COMMAND="${CYPRESS_BINARY} run \
--browser ${BROWSER} \
--headless \
--config-file ${TEST_CONFIG_FILE}\
--config ${TEST_CONFIG}\
--env ${TEST_ENV}\
--spec=${TEST_FILE_PATH}"
print_error() {
SPEC=${TEST_FILE}
COMMAND=${TEST_TYPE}
if [ "${TEST_TYPE}" = "interfer" ]; then
echo -e "\n\
CypressError: the interference user failed.\n\n\
For running this test again, you need to find the related test user.\n" >> ${ERROR_LOG}
return
fi
if [ "${TEST_TYPE}" = "multi-user" ]; then
COMMAND="multi"
SPEC=${SPEC%"_user1_spec.js"}
SPEC=${SPEC%"_user2_spec.js"}
fi
if [ "${USER_INTERFACE}" == "notebookbar" ] && [ "${TEST_TYPE}" == "desktop" ]; then
echo -e "\n\
CypressError: a test failed, please do one of the following:\n\n\
Run the failing test in headless mode:\n\
\tmake -C cypress_test USER_INTERFACE=notebookbar check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
else
echo -e "\n\
CypressError: a test failed, please do one of the following:\n\n\
Run the failing test in headless mode:\n\
\tmake -C cypress_test check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
fi
if [ "${TEST_TYPE}" == "mobile" -o "${TEST_TYPE}" == "desktop" ]; then
if [ "${USER_INTERFACE}" == "notebookbar" ]; then
echo -e "\
Run the failing test with video recording:\n\
\tmake -C cypress_test ENABLE_VIDEO_REC="1" USER_INTERFACE=notebookbar check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
else
echo -e "\
Run the failing test with video recording:\n\
\tmake -C cypress_test ENABLE_VIDEO_REC="1" check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
fi
fi
if [ "${TEST_TYPE}" != "multi-user" ]; then
if [ "${USER_INTERFACE}" == "notebookbar" ]; then
echo -e "\
Open the failing test in the interactive test runner:\n\
\tmake -C cypress_test USER_INTERFACE=notebookbar run-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
else
echo -e "\
Open the failing test in the interactive test runner:\n\
\tmake -C cypress_test run-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
fi
elif [[ ${TEST_FILE} == *"user1"* ]]; then
echo -e "\
Open the failing test in the interactive test runner:\n\
\tmake -C cypress_test run-${COMMAND} spec=${SPEC} user=1\n" >> ${ERROR_LOG}
else
echo -e "\
Open the failing test in the interactive test runner:\n\
\tmake -C cypress_test run-${COMMAND} spec=${SPEC} user=2\n" >> ${ERROR_LOG}
fi
}
mkdir -p `dirname ${TEST_LOG}`
touch ${TEST_LOG}
rm -rf ${TEST_ERROR}
echo "`echo ${RUN_COMMAND} && ${RUN_COMMAND} || touch ${TEST_ERROR}`" > ${TEST_LOG} 2>&1
if [ ! -f ${TEST_ERROR} ];
then cat ${TEST_LOG};
else echo -e "Cypress test failed: ${TEST_FILE}\n" && \
cat ${TEST_LOG} >> ${ERROR_LOG} && \
print_error;
fi;
# vim:set shiftwidth=4 expandtab: