tooling: add make commands for running unit tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5537
GitOrigin-RevId: 6427a51f729a4d4724299ea9a6a5d0e808882c86
This commit is contained in:
Daniel Harvey 2022-08-19 12:22:28 +01:00 committed by hasura-bot
parent ef0ca7dea2
commit 145fed8a7f
3 changed files with 32 additions and 0 deletions

View File

@ -20,6 +20,21 @@ define run_ghcid_hspec_tests
fi
endef
define run_ghcid_main_tests
@if [[ $$(uname -p) == 'arm' ]]; then \
HSPEC_MATCH="$(3)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
--test "main" \
--setup ":set args $(2)" \
--width=$(PANE_WIDTH) \
--height=$(PANE_HEIGHT); \
else \
HSPEC_MATCH="$(2)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
--test "main" \
--setup ":set args $(2)"; \
fi
endef
define run_ghcid
@if [[ $$(uname -p) == 'arm' ]]; then \
ghcid -c "cabal repl $(1) $(GHCID_FLAGS)" --width=$(PANE_WIDTH) --height=$(PANE_HEIGHT); \
@ -33,6 +48,11 @@ endef
ghcid-library:
$(call run_ghcid,graphql-engine:lib:graphql-engine)
.PHONY: ghcid-tests
## ghcid-tests: build and watch main tests in ghcid
ghcid-tests:
$(call run_ghcid,graphql-engine:test:graphql-engine-tests)
.PHONY: ghcid-hspec
## ghcid-hspec: build and watch tests-hspec in ghcid
ghcid-hspec:
@ -69,3 +89,9 @@ ghcid-test-citus: start-postgres start-citus remove-tix-file
ghcid-library-pro:
$(call run_ghcid,graphql-engine-pro:lib:graphql-engine-pro)
.PHONY: ghcid-test-unit
## ghcid-test-unit: build and run unit tests in ghcid
ghcid-test-unit: remove-tix-file
$(call run_ghcid_main_tests,graphql-engine:graphql-engine-tests,unit)

View File

@ -124,3 +124,4 @@ stop-everything:
.PHONY: remove-tix-file
remove-tix-file:
@ rm -f tests-hspec.tix
@ rm -f graphql-engine-tests.tix

View File

@ -29,3 +29,8 @@ test-citus: spawn-postgres spawn-citus wait-for-postgres wait-for-citus remove-t
test-backends: start-backends remove-tix-file
$(call stop_after, \
cabal run tests-hspec)
.PHONY: test-unit
## test-unit: run unit tests from main suite
test-unit: remove-tix-file
cabal run graphql-engine-tests -- unit