Skip to content

Commit 21f4f30

Browse files
authored
Update Makefile test target (#1216)
1 parent 3a6c066 commit 21f4f30

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uname -p;
2828
clang --version;
2929
- run: make test
30-
- run: sudo make test_ebpf
30+
- run: sudo make test-ebpf
3131
- run: make check-clean-work-tree
3232
generate-and-test-arm64:
3333
runs-on: macos-latest

Makefile

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ TOOLS_MOD_DIR := ./internal/tools
66
TOOLS = $(CURDIR)/.tools
77

88
ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' ! -path './LICENSES/*' -exec dirname {} \; | sort)
9+
ALL_GO_MODS := $(shell find . -type f -name 'go.mod' ! -path '$(TOOLS_MOD_DIR)/*' ! -path './LICENSES/*' | sort)
910

1011
# Build the list of include directories to compile the bpf program
1112
BPF_INCLUDE += -I${REPODIR}/internal/include/libbpf
@@ -19,7 +20,7 @@ CGO_ENABLED=0
1920
.DEFAULT_GOAL := precommit
2021

2122
.PHONY: precommit
22-
precommit: license-header-check dependabot-generate go-mod-tidy golangci-lint-fix codespell
23+
precommit: license-header-check dependabot-generate golangci-lint-fix test codespell
2324

2425
# Tools
2526
$(TOOLS):
@@ -49,22 +50,14 @@ $(TOOLS)/offsetgen: PACKAGE=go.opentelemetry.io/auto/$(TOOLS_MOD_DIR)/inspect/cm
4950
.PHONY: tools
5051
tools: $(GOLICENSES) $(MULTIMOD) $(GOLANGCI_LINT) $(DBOTCONF) $(OFFSETGEN)
5152

52-
ALL_GO_MODS := $(shell find . -type f -name 'go.mod' ! -path '$(TOOLS_MOD_DIR)/*' ! -path './LICENSES/*' | sort)
53-
GO_MODS_TO_TEST := $(ALL_GO_MODS:%=test/%)
54-
GO_MODS_TO_EBPF_TEST := $(ALL_GO_MODS:%=test_ebpf/%)
55-
56-
.PHONY: test
57-
test: generate $(GO_MODS_TO_TEST)
58-
test/%: GO_MOD=$*
59-
test/%:
60-
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v ./...
61-
62-
# These tests need to be run as privileged user/with sudo
63-
.PHONY: test_ebpf
64-
test_ebpf: generate $(GO_MODS_TO_EBPF_TEST)
65-
test_ebpf/%: GO_MOD=$*
66-
test_ebpf/%:
67-
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v -tags=ebpf_test -run ^TestEBPF ./...
53+
TEST_TARGETS := test-verbose test-ebpf
54+
.PHONY: $(TEST_TARGETS) test
55+
test-ebpf: ARGS = -tags=ebpf_test -run ^TestEBPF # These need to be run with sudo.
56+
test-verbose: ARGS = -v
57+
$(TEST_TARGETS): test
58+
test: generate $(ALL_GO_MODS:%=test/%)
59+
test/%/go.mod:
60+
@cd $* && $(GOCMD) test $(ARGS) ./...
6861

6962
.PHONY: generate
7063
generate: export CFLAGS := $(BPF_INCLUDE)

0 commit comments

Comments
 (0)