11#! /bin/bash
22set -e
33
4+ # Redirect all non-output logs to stderr
5+ exec 3>&1
6+ exec 1>&2
7+
48echo " Creating temporary files..."
59current_tests_file=$( mktemp)
610base_tests_file=$( mktemp)
711
812function cleanup {
913 echo " Cleaning up temporary files..."
1014 rm -f " $current_tests_file " " $base_tests_file "
15+ # Restore any stashed changes
16+ if git rev-parse --verify --quiet stash@{0} > /dev/null; then
17+ echo " Restoring stashed changes..."
18+ git stash pop
19+ fi
1120}
1221trap cleanup EXIT
1322
1423function extract_tests() {
1524 local file=$1
16- echo " Processing file: $file " >&2
25+ echo " Processing file: $file "
1726 # Look for test declarations and extract just the test name between quotes
1827 perl -ne ' if (/test\([' \' ' "](.+?)[' \' ' "]/) { print "$1|' $file ' \n" }' " $file "
1928}
@@ -29,6 +38,9 @@ git fetch origin main:main
2938echo " Saving current branch name..."
3039current_branch=$( git rev-parse --abbrev-ref HEAD)
3140
41+ echo " Stashing any changes..."
42+ git stash -u
43+
3244echo " Checking out main branch..."
3345git checkout main
3446
@@ -53,8 +65,11 @@ while IFS='|' read -r test_name file; do
5365 fi
5466done < " $current_tests_file "
5567
68+ # Switch back to stdout for GitHub Actions output
69+ exec 1>&3
70+
5671# Output in GitHub Actions format
57- echo " new_tests=$new_tests "
72+ echo " new_tests=${ new_tests} "
5873echo " test_details<<EOF"
59- echo -e " $test_details "
74+ echo -e " ${ test_details} "
6075echo " EOF"
0 commit comments