Skip to content

Commit e65fb8a

Browse files
jbergstroempgrange
authored andcommitted
chore(perf): cache output by set in test runner
Improve performance in the discovery phase by caching output instead of regenerating it multiple times.
1 parent fc682d5 commit e65fb8a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bash_unit

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,16 @@ maybe_shuffle() {
244244
run_tests() {
245245
local failure=0
246246

247-
local pending_tests=$(set | "$GREP" -E '^(pending|todo).* \(\)' | "$GREP" -E "$test_pattern" | "$SED" -e 's: .*::')
247+
local all_functions=$(set)
248+
249+
local pending_tests=$(echo "$all_functions" | "$GREP" -E '^(pending|todo).* \(\)' | "$GREP" -E "$test_pattern" | "$SED" -e 's: .*::')
248250
if [[ -n "$skip_pattern" ]]
249251
then
250-
local skipped_tests=$(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -E "$skip_pattern" | "$SED" -e 's: .*::')
251-
local tests_to_run="$(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -v -E "$skip_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)"
252+
local skipped_tests=$(echo "$all_functions" | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -E "$skip_pattern" | "$SED" -e 's: .*::')
253+
local tests_to_run="$(echo "$all_functions" | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -v -E "$skip_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)"
252254
else
253255
local skipped_tests=""
254-
local tests_to_run="$(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)"
256+
local tests_to_run="$(echo "$all_functions" | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)"
255257
fi
256258

257259
local test_count=$(cat "${TEST_COUNT_FILE}")

0 commit comments

Comments
 (0)