From 2ab5039c76be894cb3cf560a504719e0f552d475 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Thu, 17 Oct 2024 10:39:19 +0300 Subject: [PATCH 1/2] update bash scripts --- testdemos_files/runRegamedll.sh | 2 +- testdemos_files/runRehlds.sh | 2 +- testdemos_files/runTest.sh | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/testdemos_files/runRegamedll.sh b/testdemos_files/runRegamedll.sh index 13c713f..0f8efe8 100755 --- a/testdemos_files/runRegamedll.sh +++ b/testdemos_files/runRegamedll.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo " - Testing ReGameDLL -" +echo " - Testing ReGameDLL - " rsync -a deps/regamedll/* . demo=cstrike-basic-1 desc="CS: Testing jumping, scenarios, shooting etc" ./runTest.sh diff --git a/testdemos_files/runRehlds.sh b/testdemos_files/runRehlds.sh index 5c9fb11..764544b 100755 --- a/testdemos_files/runRehlds.sh +++ b/testdemos_files/runRehlds.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo " - Testing rehlds -" +echo " - Testing ReHLDS - " rsync -a deps/rehlds/* . demo=cstrike-muliplayer-1 desc="CS: Multiplayer" ./runTest.sh diff --git a/testdemos_files/runTest.sh b/testdemos_files/runTest.sh index 32da98f..3dd17b6 100755 --- a/testdemos_files/runTest.sh +++ b/testdemos_files/runTest.sh @@ -1,7 +1,4 @@ -# rsync -a deps/rehlds/* . - -# demo="cstrike-muliplayer-1" -# desc="CS: Multiplayer" +#!/bin/bash params=$(cat "testdemos/${demo}.params") From 848e8a545a08d43e8570b05aee436eebb7e0c03d Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Thu, 17 Oct 2024 11:29:25 +0300 Subject: [PATCH 2/2] main script refactor --- testdemos_files/runTest.sh | 60 +++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/testdemos_files/runTest.sh b/testdemos_files/runTest.sh index 3dd17b6..6979242 100755 --- a/testdemos_files/runTest.sh +++ b/testdemos_files/runTest.sh @@ -1,30 +1,44 @@ #!/bin/bash +CYAN="\e[1;36m" +YELLOW="\e[0;33m" +RED="\e[1;31m" +BOLD_RED="\e[30;41m" +BOLD_YELLOW="\e[30;43m" +RESET="\e[0m" + +ERROR_FILE="rehlds_demo_error.txt" +RESULT_FILE="result.log" + params=$(cat "testdemos/${demo}.params") - -echo -e "\e[1;36m${desc} testing...\e[0m" -echo -e " - \e[0;33mParameters: $params\e[0m" + +printf "${CYAN}%s testing...${RESET}\n" "${desc}" +printf " - ${YELLOW}Parameters: %s${RESET}\n" "$params" retVal=0 -wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demo}.bin" $params &> result.log || retVal=$? -if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then - echo -e " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸" - - if [ -f rehlds_demo_error.txt ]; then - while read line; do - echo -e " \e[1;31m$line"; - done < rehlds_demo_error.txt - else - echo -e " \e[1;33mrehlds_demo_error.txt not found, dumping result.log:\e[0m" - cat result.log - fi - echo -e " \e[30;41mExit code: $retVal\e[0m" - echo -e "\e[1;36m${desc} testing...\e[1;31m Failed ❌\e[0m" - exit 6 # Test demo failed +wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demo}.bin" $params &> "$RESULT_FILE" || retVal=$? + +if [ $retVal -eq 777 ] || [ $retVal -eq 9 ]; then + while IFS= read -r line; do + printf " ${YELLOW}%s${RESET}\n" "$line" + done <<< $(sed '/wine:/d;/./,$!d' "$RESULT_FILE") + + printf " ${BOLD_YELLOW}Exit code: %d${RESET}\n" "$retVal" + printf "${CYAN}%s testing...${YELLOW} Succeed ✔${RESET}\n" "$desc" + exit 0 +fi + +printf " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸\n" + +if [ -f "$ERROR_FILE" ]; then + while IFS= read -r line; do + printf " ${RED}%s${RESET}\n" "$line" + done < "$ERROR_FILE" else - while read line; do - echo -e " \e[0;33m$line" - done <<< $(cat result.log | sed '/wine:/d;/./,$!d') - echo -e " \e[30;43mExit code: $retVal\e[0m" - echo -e "\e[1;36m${desc} testing...\e[1;32m Succeed ✔\e[0m" + printf " ${YELLOW}rehlds_demo_error.txt not found, dumping result.log:${RESET}\n" + cat "$RESULT_FILE" fi + +printf " ${BOLD_RED}Exit code: %d${RESET}\n" "$retVal" +printf "${CYAN}%s testing...${RED} Failed ❌${RESET}\n" "$desc" +exit 1