Merge pull request #1682 from treescape-io/selective_tests

Allow selectively testing (parts) front/backend with arguments
pull/1675/merge
Piero Toffanin 2025-05-20 13:18:58 -04:00 zatwierdzone przez GitHub
commit 1548696a59
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 21 dodań i 9 usunięć

Wyświetl plik

@ -174,7 +174,7 @@ usage(){
echo " liveupdate Update WebODM to the latest release without stopping it"
echo " rebuild Rebuild all docker containers and perform cleanups"
echo " checkenv Do an environment check and install missing components"
echo " test Run the unit test suite (developers only)"
echo " test [frontend|backend] [args] Run tests (all tests, or just frontend/backend with optional arguments)"
echo " resetadminpassword \"<new password>\" Reset the administrator's password to a new one. WebODM must be running when executing this command and the password must be enclosed in double quotes."
echo ""
echo "Options:"
@ -510,17 +510,28 @@ run_tests(){
# If in a container, we run the actual test commands
# otherwise we launch this command from the container
if [[ -f /.dockerenv ]]; then
test_type=${1:-"all"}
shift || true
if [[ $test_type = "frontend" || $test_type = "all" ]]; then
echo -e "\033[1mRunning frontend tests\033[0m"
run "npm run test"
run "npm run test $*"
fi
echo "\033[1mRunning backend tests\033[0m"
run "python manage.py test"
if [[ $test_type = "backend" || $test_type = "all" ]]; then
echo -e "\033[1mRunning backend tests\033[0m"
run "python manage.py test $*"
fi
if [[ $test_type = "all" ]]; then
echo ""
echo -e "\033[1mDone!\033[0m Everything looks in order."
fi
else
environment_check
echo "Running tests in webapp container"
run "$docker_compose exec webapp /bin/bash -c \"/webodm/webodm.sh test\""
test_command="/webodm/webodm.sh test $*"
run "$docker_compose exec webapp /bin/bash -c \"$test_command\""
fi
}
@ -622,7 +633,8 @@ elif [[ $1 = "liveupdate" ]]; then
elif [[ $1 = "checkenv" ]]; then
environment_check
elif [[ $1 = "test" ]]; then
run_tests
shift || true
run_tests "$@"
elif [[ $1 = "resetadminpassword" ]]; then
resetpassword "$2"
else