File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,12 @@ unit:
198198 mkdir -p app/build && touch app/build/index.html
199199 $(UNIT )
200200
201+ # ? unit-debug: Run unit tests with debug log output enabled
202+ unit-debug :
203+ @$(call print, "Running unit tests.")
204+ mkdir -p app/build && touch app/build/index.html
205+ $(UNIT_DEBUG )
206+
201207unit-cover : $(GOACC_BIN )
202208 @$(call print, "Running unit coverage tests.")
203209 $(GOACC_BIN ) $(COVER_PKG )
@@ -308,6 +314,11 @@ sqlc-check: sqlc
308314 @$(call print, "Verifying sql code generation.")
309315 if test -n " $$ (git status --porcelain '*.go')" ; then echo " SQL models not properly generated!" ; git status --porcelain ' *.go' ; exit 1; fi
310316
317+ # ? flakehunter-unit: Run the unit tests continuously until one fails
318+ flakehunter-unit :
319+ @$(call print, "Flake hunting unit test.")
320+ scripts/unit-test-flake-hunter.sh ${pkg} ${case}
321+
311322# Prevent make from interpreting any of the defined goals as folders or files to
312323# include in the build process.
313324.PHONY : default all yarn-install build install go-build go-build-noui \
Original file line number Diff line number Diff line change @@ -51,10 +51,12 @@ UNIT_TARGETED ?= no
5151# targeted case. Otherwise, default to running all tests.
5252ifeq ($(UNIT_TARGETED ) , yes)
5353UNIT := $(GOTEST ) -tags="$(DEV_TAGS ) $(COMPILE_TAGS ) " $(TEST_FLAGS ) $(UNITPKG )
54+ UNIT_DEBUG := $(GOTEST ) -v -tags="$(DEV_TAGS ) $(COMPILE_TAGS ) " $(TEST_FLAGS ) $(UNITPKG )
5455endif
5556
5657ifeq ($(UNIT_TARGETED ) , no)
5758UNIT := $(GOLIST ) | $(XARGS ) env $(GOTEST ) -tags="$(DEV_TAGS ) $(COMPILE_TAGS ) " $(TEST_FLAGS )
59+ UNIT_DEBUG := $(GOLIST ) | $(XARGS ) env $(GOTEST ) -v -tags="$(DEV_TAGS ) $(COMPILE_TAGS ) " $(TEST_FLAGS )
5860endif
5961
6062UNIT_RACE := $(UNIT ) -race
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Check if pkg and case variables are provided.
4+ if [ $# -lt 2 ] || [ $# -gt 3 ]; then
5+ echo " Usage: $0 <pkg> <case> [timeout]"
6+ exit 1
7+ fi
8+
9+ pkg=$1
10+ case=$2
11+ timeout=${3:- 30s} # Default to 30s if not provided.
12+
13+ counter=0
14+
15+ # Run the command in a loop until it fails.
16+ while output=$( go clean -testcache && make unit-debug log=" stdlog trace" pkg=$pkg case=$case timeout=$timeout 2>&1 ) ; do
17+ (( counter++ ))
18+ echo " Test $case passed, count: $counter "
19+ done
20+
21+ # Only log the output when it fails.
22+ echo " Test $case failed. Output:"
23+ echo " $output "
You can’t perform that action at this time.
0 commit comments