Skip to content

Commit 1fef259

Browse files
committed
Used pattern for rules targetting test-*
`make help` & `make test-*` are unchanged: ``` $ make | grep test make test Run unit tests make test-core Run core unit tests make test-min Run core unit tests in minimal environment make test-min-with-upgrade Upgrade deps and run unit tests in minimal environment make test-restful Run Restful unit tests make test-with-upgrade Upgrade deps and run unit tests make test-xmlrpc Run XMLRPC unit tests $ make test -n venv/bin/python unittest-core.py venv/bin/python unittest-restful.py venv/bin/python unittest-xmlrpc.py ``` Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
1 parent 69f4a5f commit 1fef259

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

Makefile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ VENV_MIN := venv-min/bin
55
CONF := conf/glances.conf
66
PIP := $(VENV)/pip
77
PYTHON := $(VENV)/python
8-
UNITTEST := unittest
9-
8+
LASTTAG = $(shell git describe --tags --abbrev=0)
9+
10+
IMAGES_TYPES := full minimal dev
11+
ALPINE_IMAGES := $(IMAGES_TYPES:%=docker-alpine-%)
12+
UBUNTU_IMAGES := $(IMAGES_TYPES:%=docker-ubuntu-%)
13+
DOCKER_IMAGES := $(ALPINE_IMAGES) $(UBUNTU_IMAGES)
14+
DOCKER_RUNTIMES := $(DOCKER_IMAGES:%=run-%)
15+
UNIT_TESTS := test-core test-restful test-xmlrpc
1016
DOCKER_BUILD := docker buildx build
1117
DOCKER_RUN := docker run
12-
DOCKERFILE_UBUNTU := docker-files/ubuntu.Dockerfile
13-
DOCKERFILE_ALPINE := docker-files/alpine.Dockerfile
1418
PODMAN_SOCK ?= /run/user/$(shell id -u)/podman/podman.sock
1519
DOCKER_SOCK ?= /var/run/docker.sock
1620
DOCKER_SOCKS := -v $(PODMAN_SOCK):$(PODMAN_SOCK):ro -v $(DOCKER_SOCK):$(DOCKER_SOCK):ro
1721
DOCKER_OPTS := --rm -e TZ="${TZ}" -e GLANCES_OPT="" --pid host --network host
1822

19-
LASTTAG = $(shell git describe --tags --abbrev=0)
23+
define DOCKER_TAG
24+
glances:local-$*
25+
endef
2026

2127
# if the command is only `make`, the default tasks will be the printing of the help.
2228
.DEFAULT_GOAL := help
@@ -86,24 +92,22 @@ venv-dev-upgrade: ## Upgrade Python 3 dev dependencies
8692
# Tests
8793
# ===================================================================
8894

89-
test-core: ## Run core unit tests
90-
$(PYTHON) $(UNITTEST)-core.py
95+
$(UNIT_TESTS): test-%: unittest-%.py
96+
$(PYTHON) $<
9197

98+
test-core: ## Run core unit tests
9299
test-restful: ## Run Restful unit tests
93-
$(PYTHON) $(UNITTEST)-restful.py
94-
95100
test-xmlrpc: ## Run XMLRPC unit tests
96-
$(PYTHON) $(UNITTEST)-xmlrpc.py
97101

98-
test: test-core test-restful test-xmlrpc ## Run unit tests
102+
test: $(UNIT_TESTS) ## Run unit tests
99103

100104
test-with-upgrade: venv-upgrade venv-dev-upgrade test ## Upgrade deps and run unit tests
101105

102106
test-min: ## Run core unit tests in minimal environment
103-
$(VENV_MIN)/python $(UNITTEST)-core.py
107+
$(VENV_MIN)/python unittest-core.py
104108

105109
test-min-with-upgrade: venv-min-upgrade ## Upgrade deps and run unit tests in minimal environment
106-
$(VENV_MIN)/python $(UNITTEST)-core.py
110+
$(VENV_MIN)/python unittest-core.py
107111

108112
# ===================================================================
109113
# Linters, profilers and cyber security

0 commit comments

Comments
 (0)