Skip to content

Commit

Permalink
fix(tests): fail fast with Make targets
Browse files Browse the repository at this point in the history
The Make targets in `test` would not fail upon errors due the block
scope of the shell command. This issue has been fixed with a trap to
kill the test process upon failure.

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
  • Loading branch information
snprajwal committed May 9, 2023
1 parent a636799 commit c0cfc38
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ GO_VALIDATION_ERR = Go version is not supported. Please update to at least $(MIN

all: $(TEST_BINARIES) phaul-test
mkdir -p image
PID=$$(piggie/piggie) && { \
PID=$$(piggie/piggie) && \
trap 'pkill -9 piggie' EXIT && \
./test dump $$PID image && \
./test restore image; \
pkill -9 piggie; \
}
./test restore image && \
pkill -9 piggie
rm -rf image

check-go-version:
Expand All @@ -49,10 +49,10 @@ phaul/phaul: phaul/main.go

phaul-test: $(TEST_BINARIES)
rm -rf image
PID=$$(piggie/piggie) && { \
phaul/phaul $$PID; \
pkill -9 piggie; \
}
PID=$$(piggie/piggie) && \
trap 'pkill -9 piggie' EXIT && \
phaul/phaul $$PID && \
pkill -9 piggie

crit-test:
$(MAKE) -C crit
Expand Down Expand Up @@ -80,16 +80,16 @@ crit/crit-test.coverage: check-go-version crit/*.go
coverage: check-go-version $(COVERAGE_BINARIES) $(TEST_PAYLOAD)
mkdir -p $(COVERAGE_PATH)
mkdir -p image
PID=$$(piggie/piggie) && { \
PID=$$(piggie/piggie) && \
trap 'pkill -9 piggie' EXIT && \
GOCOVERDIR=${COVERAGE_PATH} ./test.coverage dump $$PID image && \
GOCOVERDIR=${COVERAGE_PATH} ./test.coverage restore image; \
pkill -9 piggie; \
}
GOCOVERDIR=${COVERAGE_PATH} ./test.coverage restore image && \
pkill -9 piggie
rm -rf image
PID=$$(piggie/piggie) && { \
GOCOVERDIR=${COVERAGE_PATH} phaul/phaul.coverage $$PID; \
pkill -9 piggie; \
}
PID=$$(piggie/piggie) && \
trap 'pkill -9 piggie' EXIT && \
GOCOVERDIR=${COVERAGE_PATH} phaul/phaul.coverage $$PID && \
pkill -9 piggie
cd crit/ && GOCOVERDIR=${COVERAGE_PATH} ./crit-test.coverage
$(MAKE) -C ../crit/ unit-test GOFLAGS="-coverprofile=${COVERAGE_PATH}/coverprofile-crit-unit-test"
$(MAKE) -C crit/ e2e-test GOCOVERDIR=${COVERAGE_PATH}
Expand Down

0 comments on commit c0cfc38

Please sign in to comment.