Skip to content

Commit d1cfa86

Browse files
FarhanAlstonairFarhanAlstonair
authored andcommitted
Add input validation to split-tests.sh script
- Validate that total-shards and shard-index are positive integers - Ensure shard-index is within valid range (1 to total-shards) - Add clear error messages for invalid inputs - Exit with non-zero status on validation failures This prevents script failures from invalid arguments and improves user experience with better error reporting.
1 parent e17303f commit d1cfa86

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/split-tests.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ if [[ -z "$TOTAL_SHARDS" || -z "$SHARD_INDEX" ]]; then
2828
exit 1
2929
fi
3030

31+
if ! [[ "$TOTAL_SHARDS" =~ ^[1-9][0-9]*$ ]]; then
32+
echo "ERROR: <total-shards> must be a positive integer."
33+
exit 1
34+
fi
35+
36+
if ! [[ "$SHARD_INDEX" =~ ^[1-9][0-9]*$ ]]; then
37+
echo "ERROR: <shard-index> must be a positive integer."
38+
exit 1
39+
fi
40+
41+
if [[ "$SHARD_INDEX" -gt "$TOTAL_SHARDS" ]]; then
42+
echo "ERROR: <shard-index> ($SHARD_INDEX) must be between 1 and <total-shards> ($TOTAL_SHARDS)."
43+
exit 1
44+
fi
45+
3146
echo "🔍 Searching for eligible JUnit test classes..."
3247

3348
ALL_TESTS=$(find . -type f -path "*/src/test/java/*.java" \

0 commit comments

Comments
 (0)