-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
31 lines (26 loc) · 1.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SHELL := /bin/bash
.DEFAULT_GOAL := all
DOCKER := docker
TAG ?= $(shell cat VERSION)
PACKAGE ?= talos-pxe
TEST_PATTERN ?= "TestLogInfo"
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
THIS_FILE := $(lastword $(MAKEFILE_LIST))
.PHONY: unittest-local unittest build-unittest all
all:
$(info Currently the make is used only for running tests)
@$(MAKE) -f $(THIS_FILE) unittest
build-unittest:
$(DOCKER) build -t talos-pxe:unittest-${PACKAGE}-${TAG} --target unittest .
unittest-local:
# we want the test output in file by tee but also the exit status to fail on test failure hence the set -o pipefail
set -o pipefail; go test -cover -v ./... -coverprofile=out/coverage.out 2>&1 | tee out/unittest.out
go tool cover -html=out/coverage.out -o out/coverage.html
unittest: build-unittest
# TODO replace this volume mount with copying the coverage files out from container after done
$(DOCKER) run -t -v ${ROOT_DIR}:/go/src/github.com/borancar/talos-pxe:Z \
--rm talos-pxe:unittest-${PACKAGE}-${TAG}
unittest-one: build-unittest
$(DOCKER) run -t -v ${ROOT_DIR}:/go/src/github.com/borancar/talos-pxe:Z \
--rm --entrypoint bash \
talos-pxe:unittest-${PACKAGE}-${TAG} -c "go test -v -run $(TEST_PATTERN)"