|
1 | 1 | .DEFAULT: test
|
2 | 2 |
|
3 |
| -test: test-go test-tinygo test-integration |
4 | 3 | .PHONY: test
|
5 |
| - |
6 |
| -# Makes tools/viceroy available as an executable within Makefile recipes. |
7 |
| -PATH := $(PWD)/tools:$(PATH) |
| 4 | +test: test-go test-tinygo test-integration test-e2e |
8 | 5 |
|
9 | 6 | # Override these with environment variables or directly on the make command line.
|
10 | 7 | GO_BUILD_FLAGS := -tags=fastlyinternaldebug,nofastlyhostcalls
|
11 | 8 | GO_TEST_FLAGS := -v
|
12 | 9 | GO_PACKAGES := ./...
|
13 | 10 |
|
| 11 | +.PHONY: test-go |
14 | 12 | test-go:
|
| 13 | + @echo ">> Running Go tests..." >&2 |
15 | 14 | go test $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
|
16 |
| -.PHONY: test-go |
17 | 15 |
|
18 | 16 | # Using this target lets viceroy provide the wasm runtime, eliminating a dependency on wasmtime.
|
19 | 17 | TINYGO_TARGET := ./targets/fastly-compute-wasip1.json
|
20 | 18 |
|
21 |
| -test-tinygo: |
22 |
| - tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
23 | 19 | .PHONY: test-tinygo
|
| 20 | +test-tinygo: viceroy |
| 21 | + @echo ">> Running TinyGo tests..." >&2 |
| 22 | + tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
24 | 23 |
|
25 | 24 | # Integration tests use viceroy and override the default values for these variables.
|
26 | 25 | test-integration-%: GO_BUILD_FLAGS := -tags=fastlyinternaldebug
|
27 | 26 | test-integration-%: GO_PACKAGES := ./integration_tests/...
|
28 | 27 |
|
29 |
| -test-integration: test-integration-go test-integration-tinygo |
| 28 | + |
30 | 29 | .PHONY: test-integration
|
| 30 | +test-integration: test-integration-go test-integration-tinygo |
31 | 31 |
|
32 |
| -test-integration-go: tools/viceroy |
33 |
| - GOARCH=wasm GOOS=wasip1 go test -exec "viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
34 | 32 | .PHONY: test-integration-go
|
| 33 | +test-integration-go: viceroy |
| 34 | + @echo ">> Running Go integration tests..." >&2 |
| 35 | + GOARCH=wasm GOOS=wasip1 go test -exec "viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
35 | 36 |
|
36 |
| -test-integration-tinygo: tools/viceroy |
37 |
| - tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
38 | 37 | .PHONY: test-integration-tinygo
|
| 38 | +test-integration-tinygo: viceroy |
| 39 | + @echo ">> Running TinyGo integration tests..." >&2 |
| 40 | + tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
| 41 | + |
| 42 | +# End to end tests use serve.sh and override the default values for these variables. |
| 43 | +test-e2e-%: GO_BUILD_FLAGS := -tags=fastlyinternaldebug |
| 44 | +test-e2e-%: GO_PACKAGES := ./end_to_end_tests/... |
| 45 | +test-e2e-%: export PATH := $(PWD)/end_to_end_tests:$(PATH) # allows go test to find serve.sh |
| 46 | + |
| 47 | +.PHONY: test-e2e |
| 48 | +test-e2e: test-e2e-go test-e2e-tinygo |
| 49 | + |
| 50 | +.PHONY: test-e2e-go |
| 51 | +test-e2e-go: viceroy |
| 52 | + @echo ">> Running Go end-to-end tests..." >&2 |
| 53 | + GOARCH=wasm GOOS=wasip1 go test -exec "serve.sh viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
| 54 | + |
| 55 | +.PHONY: test-e2e-tinygo |
| 56 | +test-e2e-tinygo: TINYGO_TARGET := ./targets/fastly-compute-wasip1-serve.json |
| 57 | +test-e2e-tinygo: viceroy |
| 58 | + @echo ">> Running TinyGo end-to-end tests..." >&2 |
| 59 | + tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) |
39 | 60 |
|
40 |
| -tools/viceroy: | tools # Download latest version of Viceroy ./tools/viceroy; delete it if you'd like to upgrade |
41 |
| - @arch=$$(uname -m | sed 's/x86_64/amd64/'); \ |
42 |
| - os=$$(uname -s | tr '[:upper:]' '[:lower:]'); \ |
43 |
| - url=$$(curl -s https://api.github.com/repos/fastly/viceroy/releases/latest | jq --arg arch $$arch --arg os $$os -r '.assets[] | select((.name | contains($$arch)) and (.name | contains($$os))) | .browser_download_url'); \ |
44 |
| - filename=$$(basename $$url); \ |
45 |
| - curl -sSLO $$url && \ |
46 |
| - tar -xzf $$filename --directory ./tools/ && \ |
47 |
| - rm $$filename && \ |
48 |
| - ./tools/viceroy --version && \ |
49 |
| - touch ./tools/viceroy |
50 |
| -ifneq ($(strip $(GITHUB_PATH)),) |
51 |
| - @echo "$(PWD)/tools" >> "$(GITHUB_PATH)" |
52 |
| -endif |
53 |
| - |
54 |
| -tools: |
55 |
| - @mkdir -p tools |
56 |
| - |
57 |
| -viceroy-update: |
58 |
| - @rm -f tools/viceroy |
59 |
| - @$(MAKE) tools/viceroy |
60 |
| -.PHONY: viceroy-update |
| 61 | +.PHONY: viceroy |
| 62 | +viceroy: |
| 63 | + @which viceroy || ( \ |
| 64 | + echo "viceroy not found: please ensure it is installed and available in your PATH:" && \ |
| 65 | + echo $$PATH && \ |
| 66 | + echo && \ |
| 67 | + echo "The fastly CLI installs Viceroy in the fastly subdirectory of the path returned by" && \ |
| 68 | + echo "os.UserConfigDir():" && \ |
| 69 | + echo " > On Unix systems, it returns \$$XDG_CONFIG_HOME if non-empty, else \$$HOME/.config." && \ |
| 70 | + echo " > On Darwin, it returns \$$HOME/Library/Application Support." && \ |
| 71 | + echo "From https://pkg.go.dev/os#UserConfigDir" && \ |
| 72 | + exit 1 \ |
| 73 | + ) |
0 commit comments