Skip to content

Commit 7c7c213

Browse files
committed
non-zero exit code on fail
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
1 parent 420ab36 commit 7c7c213

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ GLJ-IMPORTS=$(foreach platform,$(GO-PLATFORMS) \
6969
GLJ-BINS=$(foreach platform,$(GO-PLATFORMS) \
7070
,bin/$(platform)/glj$(if $(findstring wasm,$(platform)),.wasm,))
7171

72+
TEST-RUNNER-BIN := bin/glj-test
73+
7274
GO-CMD := go$(GO-VERSION)
7375

7476
ALL-TARGETS := \
@@ -156,7 +158,7 @@ bin/%/glj.wasm: \
156158
vet:
157159
go vet ./...
158160

159-
.PHONY: test
161+
.PHONY: test test-runner
160162
# vet is disabled until we fix errors in generated code
161163
test: test-glj test-suite # vet
162164

@@ -169,6 +171,23 @@ test-suite: $(GLJ-CMD)
169171
--expect-errors 151 \
170172
2>/dev/null
171173

174+
# Build the test runner
175+
$(TEST-RUNNER-BIN): cmd/glj-test/main.go pkg/stdlib/glojure/test_runner.glj
176+
go build -o $@ ./cmd/glj-test
177+
178+
# Run tests with the new test runner
179+
test-runner:
180+
go run ./cmd/glj-test --dir test/glojure --verbose
181+
182+
# Run specific test namespace with test runner
183+
test-ns:
184+
@if [ -z "$(NS)" ]; then \
185+
echo "Usage: make test-ns NS=pattern"; \
186+
echo "Example: make test-ns NS=basic"; \
187+
exit 1; \
188+
fi
189+
go run ./cmd/glj-test --dir test/glojure --namespace ".*$(NS).*" --verbose
190+
172191
$(TEST-GLJ-TARGETS): $(GLJ-CMD)
173192
$< $(basename $@)
174193

pkg/stdlib/glojure/test_runner.glj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@
146146

147147
(defmethod report-results :edn
148148
[_ results output]
149-
(prn results))
149+
(prn results)
150+
(when (or (> (:fail results) 0) (> (:error results) 0))
151+
(os.Exit 1)))
150152

151153
(defmethod report-results :junit
152154
[_ results output]
153155
;; TODO: Implement JUnit XML output
154-
(println "JUnit format not yet implemented"))
156+
(println "JUnit format not yet implemented")
157+
(when (or (> (:fail results) 0) (> (:error results) 0))
158+
(os.Exit 1)))
155159

156160
(defn run-tests
157161
"Main entry point for running tests"
@@ -213,7 +217,11 @@
213217
:verbose verbose})))
214218

215219
;; Report results
216-
(report-results format @test-results output)))))
220+
(report-results format @test-results output)
221+
222+
;; Ensure we exit with success if we get here
223+
;; (report-results should have already exited with 1 if there were failures)
224+
(os.Exit 0)))))
217225

218226
;; Default run function for command-line usage
219227
(defn -main [& args]

0 commit comments

Comments
 (0)