Support running unit tests when files are saved.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-05-15 17:00:35 -04:00
parent a2225276af
commit 74c06a140b
5 changed files with 24 additions and 2 deletions

View File

@ -19,7 +19,6 @@ test:
lint: lint:
@gometalinter --config gometalinter.json ./... @gometalinter --config gometalinter.json ./...
.PHONY: binary .PHONY: binary
binary: binary:
@./scripts/build/binary @./scripts/build/binary
@ -33,6 +32,10 @@ cross:
dynbinary: dynbinary:
@./scripts/build/dynbinary @./scripts/build/dynbinary
.PHONY: watch
watch:
@./scripts/test/watch
# download dependencies (vendor/) listed in vendor.conf # download dependencies (vendor/) listed in vendor.conf
.PHONY: vendor .PHONY: vendor
vendor: vendor.conf vendor: vendor.conf

View File

@ -28,7 +28,6 @@ Run all linting:
``` ```
$ make -f docker.Makefile lint $ make -f docker.Makefile lint
``` ```
`
### In-container development environment ### In-container development environment

View File

@ -46,6 +46,10 @@ test: build_docker_image
cross: build_cross_image cross: build_cross_image
@docker run --rm $(MOUNTS) $(CROSS_IMAGE_NAME) make cross @docker run --rm $(MOUNTS) $(CROSS_IMAGE_NAME) make cross
.PHONY: watch
watch: build_docker_image
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make watch
# start container in interactive mode for in-container development # start container in interactive mode for in-container development
.PHONY: dev .PHONY: dev
dev: build_docker_image dev: build_docker_image

View File

@ -15,6 +15,10 @@ RUN go get github.com/jteeuwen/go-bindata/go-bindata && \
cp /go/bin/go-bindata /usr/bin && \ cp /go/bin/go-bindata /usr/bin && \
rm -rf /go/src/* /go/pkg/* /go/bin/* rm -rf /go/src/* /go/pkg/* /go/bin/*
RUN go get github.com/dnephin/filewatcher && \
cp /go/bin/filewatcher /usr/bin/ && \
rm -rf /go/src/* /go/pkg/* /go/bin/*
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
WORKDIR /go/src/github.com/docker/cli WORKDIR /go/src/github.com/docker/cli
CMD sh CMD sh

12
scripts/test/watch Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
filewatcher \
-L 5 \
-x '**/*.swp' \
-x .git \
-x build \
-x .idea \
-- \
sh -c 'go test -timeout 10s -v ./${dir} || ( echo; echo; exit 1 )'