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:
37
.github/workflows/test.sh
vendored
Executable file
37
.github/workflows/test.sh
vendored
Executable 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"
|
||||
Reference in New Issue
Block a user