Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up Makefile test target #1216

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uname -p;
clang --version;
- run: make test
- run: sudo make test_ebpf
- run: sudo make test-ebpf
- run: make check-clean-work-tree
generate-and-test-arm64:
runs-on: macos-latest
Expand Down
27 changes: 10 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TOOLS_MOD_DIR := ./internal/tools
TOOLS = $(CURDIR)/.tools

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

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

.PHONY: precommit
precommit: license-header-check dependabot-generate go-mod-tidy golangci-lint-fix codespell
precommit: license-header-check dependabot-generate golangci-lint-fix test codespell

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

ALL_GO_MODS := $(shell find . -type f -name 'go.mod' ! -path '$(TOOLS_MOD_DIR)/*' ! -path './LICENSES/*' | sort)
GO_MODS_TO_TEST := $(ALL_GO_MODS:%=test/%)
GO_MODS_TO_EBPF_TEST := $(ALL_GO_MODS:%=test_ebpf/%)

.PHONY: test
test: generate $(GO_MODS_TO_TEST)
test/%: GO_MOD=$*
test/%:
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v ./...

# These tests need to be run as privileged user/with sudo
.PHONY: test_ebpf
test_ebpf: generate $(GO_MODS_TO_EBPF_TEST)
test_ebpf/%: GO_MOD=$*
test_ebpf/%:
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v -tags=ebpf_test -run ^TestEBPF ./...
TEST_TARGETS := test-verbose test-ebpf
.PHONY: $(TEST_TARGETS) test
test-ebpf: ARGS = -tags=ebpf_test -run ^TestEBPF # These need to be run with sudo.
test-verbose: ARGS = -v
$(TEST_TARGETS): test
test: generate $(ALL_GO_MODS:%=test/%)
test/%/go.mod:
@cd $* && $(GOCMD) test $(ARGS) ./...

.PHONY: generate
generate: export CFLAGS := $(BPF_INCLUDE)
Expand Down
Loading