Skip to content

Commit 2f58149

Browse files
committed
test: enable root for RequiresRoot cases
Signed-off-by: Wei Fu <[email protected]>
1 parent 75bee3e commit 2f58149

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ script:
3030
- ../project/script/validate/vendor
3131
- make build binaries
3232
- if [ "$GOOS" = "linux" ]; then make vet test; fi
33+
- if [ "$GOOS" = "linux" ]; then sudo PATH=$PATH GOPATH=$GOPATH make root-test; fi
3334
- if [ "$GOOS" != "linux" ]; then make test-compile; fi

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
2020

2121
GO_LDFLAGS=-ldflags "-X `go list ./version`.Version=$(VERSION)"
2222

23+
PKG=github.com/containerd/continuity
24+
2325
PACKAGES=$(shell go list ./... | grep -v /vendor/)
26+
TEST_REQUIRES_ROOT_PACKAGES=$(filter \
27+
${PACKAGES}, \
28+
$(shell \
29+
for f in $$(git grep -l testutil.RequiresRoot | grep -v Makefile); do \
30+
d="$$(dirname $$f)"; \
31+
[ "$$d" = "." ] && echo "${PKG}" && continue; \
32+
echo "${PKG}/$$d"; \
33+
done | sort -u) \
34+
)
2435

2536
.PHONY: clean all fmt vet lint build test binaries setup
2637
.DEFAULT: default
@@ -68,6 +79,10 @@ test:
6879
@echo "+ $@"
6980
@go test $(PACKAGES)
7081

82+
root-test:
83+
@echo "+ $@"
84+
@go test ${TEST_REQUIRES_ROOT_PACKAGES} -test.root
85+
7186
test-compile:
7287
@echo "+ $@"
7388
@for pkg in $(PACKAGES); do go test -c $$pkg; done

0 commit comments

Comments
 (0)