From c4a836ba29422c0c4bdc45e955fc623c5432d49b Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 20 Aug 2022 22:47:07 +0700 Subject: all: add tasks to setup test inside systemd container When running test inside container, sometimes its success, most of the time its fail. In order to replicate it we need to setup the same container environment and inspect it. --- Makefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9054629..b2dc909 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ lint: test: go run ./cmd/ciigo-example embed - CGO_ENABLED=1 go test -v -race ./... + CGO_ENABLED=1 go test -failfast -v -race -p=1 ./... install: build mv _bin/ciigo $(GOBIN) @@ -25,3 +25,20 @@ run-example: build: mkdir -p $(DIR_BUILD) CGO_ENABLED=0 go build $(LDFLAGS) -o $(DIR_BUILD) ./cmd/... + +.PHONY: chroot-setup chroot-test + +chroot-setup: + sudo mkdir -p /var/lib/machines/arch.test + sudo pacstrap -c /var/lib/machines/arch.test base-devel systemd go + sudo mkdir /var/lib/machines/arch.test/root/ciigo + +chroot-test: + sudo rsync -r . /var/lib/machines/arch.test/root/ciigo/ + sudo systemd-nspawn --bind=/tmp \ + --bind=$${HOME}/go/pkg:/root/go/pkg \ + --bind=$${PWD}/../share:/root/share \ + --bind=$${HOME}/.cache/go-build:/root/.cache/go-build \ + -D /var/lib/machines/arch.test \ + make -C /root/ciigo test + #sh -c "rm -rf /root/test; mkdir /root/test; stat /root/test; sleep 1; touch /root/test/file; stat /root/test" -- cgit v1.3