2020-07-23 06:23:14 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
2020-10-09 14:19:44 -05:00
|
|
|
|
|
|
|
if [ -z "${NODE_PATH}" ]; then
|
|
|
|
BUILDDIR=${DIR}
|
|
|
|
else
|
|
|
|
BUILDDIR=$(dirname ${NODE_PATH})
|
|
|
|
fi
|
|
|
|
|
|
|
|
CYPRESS_BINARY="${BUILDDIR}/node_modules/cypress/bin/cypress"
|
2020-07-23 06:23:14 -05:00
|
|
|
DESKTOP_TEST_FOLDER="${DIR}/integration_tests/desktop/"
|
|
|
|
MOBILE_TEST_FOLDER="${DIR}/integration_tests/mobile/"
|
|
|
|
MULTIUSER_TEST_FOLDER="${DIR}/integration_tests/multiuser/"
|
2020-10-09 14:19:44 -05:00
|
|
|
ERROR_LOG="${BUILDDIR}/workdir/error.log"
|
2020-07-23 06:23:14 -05:00
|
|
|
|
|
|
|
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=
|
2023-06-22 13:43:00 -05:00
|
|
|
TEST_CONFIG_FILE=
|
2020-07-23 06:23:14 -05:00
|
|
|
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;;
|
2023-06-22 13:43:00 -05:00
|
|
|
--config-file) TEST_CONFIG_FILE=$2; shift;;
|
2020-07-23 06:23:14 -05:00
|
|
|
--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
|
2020-07-23 11:33:09 -05:00
|
|
|
TEST_ERROR="${TEST_LOG}.error"
|
2020-07-23 06:23:14 -05:00
|
|
|
|
|
|
|
TEST_FILE_PATH=
|
2021-02-05 06:11:55 -06:00
|
|
|
if [ "${TEST_TYPE}" = "desktop" -o "${TEST_TYPE}" = "interfer-desktop" ]; then
|
2020-07-23 06:23:14 -05:00
|
|
|
TEST_FILE_PATH=${DESKTOP_TEST_FOLDER}${TEST_FILE};
|
2021-02-05 06:11:55 -06:00
|
|
|
elif [ "${TEST_TYPE}" = "mobile" -o "${TEST_TYPE}" = "interfer-mobile" ]; then
|
2020-07-23 06:23:14 -05:00
|
|
|
TEST_FILE_PATH=${MOBILE_TEST_FOLDER}${TEST_FILE};
|
2021-07-12 04:46:50 -05:00
|
|
|
elif [ "${TEST_TYPE}" = "multi-user" ]; then
|
2021-02-05 06:11:55 -06:00
|
|
|
TEST_FILE_PATH=${MULTIUSER_TEST_FOLDER}${TEST_FILE};
|
2021-07-12 04:46:50 -05:00
|
|
|
elif [ "${TEST_TYPE}" = "interfer" ]; then
|
|
|
|
TEST_FILE_PATH="${DIR}/integration_tests/common/"${TEST_FILE};
|
2020-07-23 06:23:14 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
RUN_COMMAND="${CYPRESS_BINARY} run \
|
|
|
|
--browser ${BROWSER} \
|
|
|
|
--headless \
|
2023-06-22 13:43:00 -05:00
|
|
|
--config-file ${TEST_CONFIG_FILE}\
|
2020-07-23 06:23:14 -05:00
|
|
|
--config ${TEST_CONFIG}\
|
|
|
|
--env ${TEST_ENV}\
|
|
|
|
--spec=${TEST_FILE_PATH}"
|
|
|
|
|
|
|
|
print_error() {
|
2020-07-29 05:06:10 -05:00
|
|
|
SPEC=${TEST_FILE}
|
|
|
|
COMMAND=${TEST_TYPE}
|
2021-02-05 06:11:55 -06:00
|
|
|
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
|
|
|
|
|
2020-07-29 05:06:10 -05:00
|
|
|
if [ "${TEST_TYPE}" = "multi-user" ]; then
|
|
|
|
COMMAND="multi"
|
|
|
|
SPEC=${SPEC%"_user1_spec.js"}
|
|
|
|
SPEC=${SPEC%"_user2_spec.js"}
|
|
|
|
fi
|
2021-08-24 01:58:46 -05:00
|
|
|
|
|
|
|
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\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test USER_INTERFACE=notebookbar check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
else
|
|
|
|
echo -e "\n\
|
|
|
|
CypressError: a test failed, please do one of the following:\n\n\
|
|
|
|
Run the failing test in headless mode:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
fi
|
2021-02-19 03:39:47 -06:00
|
|
|
|
|
|
|
if [ "${TEST_TYPE}" == "mobile" -o "${TEST_TYPE}" == "desktop" ]; then
|
2021-08-24 01:58:46 -05:00
|
|
|
if [ "${USER_INTERFACE}" == "notebookbar" ]; then
|
|
|
|
echo -e "\
|
|
|
|
Run the failing test with video recording:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test ENABLE_VIDEO_REC="1" USER_INTERFACE=notebookbar check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
else
|
|
|
|
echo -e "\
|
|
|
|
Run the failing test with video recording:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test ENABLE_VIDEO_REC="1" check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
fi
|
2021-02-19 03:39:47 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${TEST_TYPE}" != "multi-user" ]; then
|
2021-08-24 01:58:46 -05:00
|
|
|
if [ "${USER_INTERFACE}" == "notebookbar" ]; then
|
|
|
|
echo -e "\
|
|
|
|
Open the failing test in the interactive test runner:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test USER_INTERFACE=notebookbar run-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
else
|
|
|
|
echo -e "\
|
|
|
|
Open the failing test in the interactive test runner:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test run-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
|
2021-08-24 01:58:46 -05:00
|
|
|
fi
|
2020-08-07 07:20:42 -05:00
|
|
|
elif [[ ${TEST_FILE} == *"user1"* ]]; then
|
|
|
|
echo -e "\
|
|
|
|
Open the failing test in the interactive test runner:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test run-${COMMAND} spec=${SPEC} user=1\n" >> ${ERROR_LOG}
|
2020-08-07 07:20:42 -05:00
|
|
|
else
|
|
|
|
echo -e "\
|
|
|
|
Open the failing test in the interactive test runner:\n\
|
2022-02-26 03:24:56 -06:00
|
|
|
\tmake -C cypress_test run-${COMMAND} spec=${SPEC} user=2\n" >> ${ERROR_LOG}
|
2020-07-29 05:06:10 -05:00
|
|
|
fi
|
2020-07-23 06:23:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
mkdir -p `dirname ${TEST_LOG}`
|
|
|
|
touch ${TEST_LOG}
|
2020-08-31 07:58:20 -05:00
|
|
|
rm -rf ${TEST_ERROR}
|
2020-09-17 08:30:31 -05:00
|
|
|
echo "`echo ${RUN_COMMAND} && ${RUN_COMMAND} || touch ${TEST_ERROR}`" > ${TEST_LOG} 2>&1
|
2021-02-16 07:26:16 -06:00
|
|
|
if [ ! -f ${TEST_ERROR} ];
|
|
|
|
then cat ${TEST_LOG};
|
|
|
|
else echo -e "Cypress test failed: ${TEST_FILE}\n" && \
|
|
|
|
cat ${TEST_LOG} >> ${ERROR_LOG} && \
|
2020-07-23 06:23:14 -05:00
|
|
|
print_error;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
# vim:set shiftwidth=4 expandtab:
|