-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds coverage logic customized from func-e (#596)
This adds coverage the same way as works in func-e, just that there are slightly different conventions here wrt packages to ignore. Notably, we should not run coverage using integration tests or examples as they give false positives. Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
d992373
commit f1467e5
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ go.work | |
# AssemblyScript | ||
node_modules | ||
package-lock.json | ||
|
||
# codecov.io | ||
/coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
|
||
# Make functions strip spaces and use commas to separate parameters. The below variables escape these characters. | ||
comma := , | ||
space := | ||
space += | ||
|
||
goimports := golang.org/x/tools/cmd/[email protected] | ||
golangci_lint := github.com/golangci/golangci-lint/cmd/[email protected] | ||
# sync this with netlify.toml! | ||
hugo := github.com/gohugoio/[email protected] | ||
|
||
# Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion. | ||
all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go) | ||
all_testdata := $(wildcard testdata/* */testdata/* */*/testdata/* */*/*/testdata/*) | ||
all_testing := $(wildcard internal/testing/* internal/testing/*/* internal/testing/*/*/*) | ||
all_examples := $(wildcard examples/* examples/*/* examples/*/*/*) | ||
all_it := $(wildcard internal/integration_test/* internal/integration_test/*/* internal/integration_test/*/*/*) | ||
# main_sources exclude any test or example related code | ||
main_sources := $(wildcard $(filter-out %_test.go $(all_testdata) $(all_testing) $(all_examples) $(all_it), $(all_sources))) | ||
# main_packages collect the unique main source directories (sort will dedupe). | ||
# Paths need to all start with ./, so we do that manually vs foreach which strips it. | ||
main_packages := $(sort $(foreach f,$(dir $(main_sources)),$(if $(findstring ./,$(f)),./,./$(f)))) | ||
|
||
ensureCompilerFastest := -ldflags '-X github.com/tetratelabs/wazero/internal/integration_test/vs.ensureCompilerFastest=true' | ||
.PHONY: bench | ||
bench: | ||
|
@@ -71,7 +89,6 @@ build.spectest.v1: # Note: wabt by default uses >1.0 features, so wast2json flag | |
--debug-names $$f; \ | ||
done | ||
|
||
|
||
.PHONY: build.spectest.v2 | ||
build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory. | ||
@mkdir -p $(spectest_v2_testdata_dir) | ||
|
@@ -88,6 +105,12 @@ test: | |
@go test $$(go list ./... | grep -v spectest) -timeout 120s | ||
@cd internal/integration_test/asm && go test ./... -timeout 120s | ||
|
||
.PHONY: coverage | ||
coverpkg = $(subst $(space),$(comma),$(main_packages)) | ||
coverage: ## Generate test coverage | ||
@go test -coverprofile=coverage.txt -covermode=atomic --coverpkg=$(coverpkg) $(main_packages) | ||
@go tool cover -func coverage.txt | ||
|
||
.PHONY: spectest | ||
spectest: | ||
@$(MAKE) spectest.v1 | ||
|
@@ -134,3 +157,8 @@ check: | |
site: ## Serve website content | ||
@git submodule update --init | ||
@cd site && go run $(hugo) server --minify --disableFastRender --baseURL localhost:1313 --cleanDestinationDir -D | ||
|
||
.PHONY: clean | ||
clean: ## Ensure a clean build | ||
@rm -rf dist build coverage.txt | ||
@go clean -testcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Codecov for main is visible here https://app.codecov.io/gh/tetratelabs/wazero | ||
|
||
# We use codecov only as a UI, so we disable PR comments. | ||
# See https://docs.codecov.com/docs/pull-request-comments | ||
comment: false |