added new test.sh script

The test.sh script will run the cargo test and save a formatted output
from each project and then append them to a final log file which will be
the data to be uploaded to the spreadsheet
This commit is contained in:
2025-11-07 12:54:11 +01:00
parent 86ceab10ad
commit bc2eca7eac
4 changed files with 40 additions and 9 deletions

View File

@@ -14,6 +14,4 @@ jobs:
- name: Run Engine tests
run: |
cd engine
pwd
cargo test --verbose
bash .github/workflows/test.sh engine/

View File

@@ -14,6 +14,4 @@ jobs:
- name: Run Server tests
run: |
cd server
pwd
cargo test --verbose
bash .github/workflows/test.sh server/

37
.github/workflows/test.sh vendored Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e
# --- ARGUMENT CHECK ---
if [ -z "$1" ]; then
echo "Usage: $0 <project_path>"
exit 1
fi
# --- SETUP VARIABLES ---
PROJECT_PATH="$1"
PROJECT_NAME=$(basename "$PROJECT_PATH")
ROOT_DIR=$(git rev-parse --show-toplevel)
LOG_FILE="${PROJECT_NAME}_test.log"
FINAL_LOG="${ROOT_DIR}/test_data.log"
# --- MOVE TO PROJECT DIRECTORY ---
echo ">>> Running tests for project: $PROJECT_NAME"
cd "$PROJECT_PATH" || { echo "Error: Could not cd into $PROJECT_PATH"; exit 1; }
# --- RUN TESTS ---
cargo test --verbose | tee full_test_output.log
# --- EXTRACT TEST SECTION ---
# Create the log file with the project name as the first line
echo "$PROJECT_NAME" > "$LOG_FILE"
# Then append only the lines between "running X test(s)" and the first empty line
awk '/^running [0-9]+ test[s]?$/,/^$/' full_test_output.log >> "$LOG_FILE"
# --- APPEND TO GLOBAL LOG (in repo root) ---
cat "$LOG_FILE" >> "$FINAL_LOG"
# --- SUMMARY ---
echo ">>> Test output extracted to $PROJECT_PATH/$LOG_FILE"
echo ">>> Appended to $FINAL_LOG"

View File

@@ -14,6 +14,4 @@ jobs:
- name: Run UI tests
run: |
cd ui
pwd
cargo test --verbose
bash .github/workflows/test.sh ui/