11#! /bin/bash
22set -e
33
4- # Redirect all non-output logs to stderr
5- exec 3>&1
6- exec 1>&2
7-
8- echo " Creating temporary files..."
4+ # Create temporary files
95current_tests_file=$( mktemp)
106base_tests_file=$( mktemp)
117
128function cleanup {
13- echo " Cleaning up temporary files..."
149 rm -f " $current_tests_file " " $base_tests_file "
1510 # Restore any stashed changes
1611 if git rev-parse --verify --quiet stash@{0} > /dev/null; then
17- echo " Restoring stashed changes..."
18- git stash pop
12+ git stash pop > /dev/null 2>&1
1913 fi
2014}
2115trap cleanup EXIT
2216
2317function extract_tests() {
2418 local file=$1
25- echo " Processing file: $file "
2619 # Look for test declarations and extract just the test name between quotes
27- perl -ne ' if (/test\([' \' ' "](.+?)[' \' ' "]/) { print "$1|' $file ' \n" }' " $file "
20+ perl -ne ' if (/^\s* test\([' \' ' "](.+?)[' \' ' "]/) { print "$1|' $file ' \n" }' " $file " 2> /dev/null
2821}
2922
30- echo " Extracting current branch tests..."
31- while IFS= read -r file; do
32- extract_tests " $file "
33- done < <( find tests/suites -type f -name " *.test.ts" ) | sort > " $current_tests_file "
34-
35- echo " Fetching main branch..."
36- git fetch origin main:main
23+ # Stash any changes
24+ git stash -u > /dev/null 2>&1 || true
3725
38- echo " Saving current branch name... "
26+ # Save current branch name
3927current_branch=$( git rev-parse --abbrev-ref HEAD)
4028
41- echo " Stashing any changes..."
42- git stash -u
29+ # Extract current branch tests
30+ while IFS= read -r file; do
31+ extract_tests " $file "
32+ done < <( find tests/suites -type f -name " *.test.ts" ) | sort > " $current_tests_file "
4333
44- echo " Checking out main branch..."
45- git checkout main
34+ # Switch to main branch
35+ git fetch origin main:main > /dev/null 2>&1
36+ git checkout main > /dev/null 2>&1
4637
47- echo " Extracting main branch tests... "
38+ # Extract main branch tests
4839while IFS= read -r file; do
4940 if [ -f " $file " ]; then
5041 extract_tests " $file "
5142 fi
5243done < <( find tests/suites -type f -name " *.test.ts" ) | sort > " $base_tests_file "
5344
54- echo " Returning to original branch... "
55- git checkout " $current_branch "
45+ # Return to original branch
46+ git checkout " $current_branch " > /dev/null 2>&1
5647
57- echo " Comparing test files... "
48+ # Compare and collect results
5849new_tests=0
5950test_details=" "
6051
@@ -65,9 +56,6 @@ while IFS='|' read -r test_name file; do
6556 fi
6657done < " $current_tests_file "
6758
68- # Switch back to stdout for GitHub Actions output
69- exec 1>&3
70-
7159# Output in GitHub Actions format
7260echo " new_tests=${new_tests} "
7361echo " test_details<<EOF"
0 commit comments