Skip to content

Commit

Permalink
Support BSD sed and older bash in test rule. (#112)
Browse files Browse the repository at this point in the history
BSD sed (as shipped with MacOS) does not support `+` nor `\+` in regular expressions.
However it does support `\{1,\}` which does the same thing and is also supported by GNU sed.

Moreover, bash 3.2 (as shipped with MacOS) does not seem to support `source <(...)`, it seems to just do nothing.
Using plain eval seems to do the trick though.
  • Loading branch information
porridge committed Nov 18, 2021
1 parent 1be4e1a commit 70c7509
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ all: test lint build
# https://github.com/kubernetes-sigs/kubebuilder/pull/2287 targeting the kubebuilder
# "tools-releases" branch. Make sure to look up the appropriate etcd version in the
# kubernetes release notes for the minor version you're building tools for.
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\+\)\.[[:digit:]]\+$$/1.\1.x/')
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
TESTPKG ?= ./...
# TODO: Modify this to use setup-envtest binary
test: build
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
source <(setup-envtest use -p env $(ENVTEST_VERSION)) && go test -race -covermode atomic -coverprofile cover.out $(TESTPKG)
eval $$(setup-envtest use -p env $(ENVTEST_VERSION)) && go test -race -covermode atomic -coverprofile cover.out $(TESTPKG)

.PHONY: test-sanity
test-sanity: generate fix ## Test repo formatting, linting, etc.
Expand Down

0 comments on commit 70c7509

Please sign in to comment.