summaryrefslogtreecommitdiff
path: root/EndoForge/test/Makefile
blob: 3bc1a66065a0e3a499a7c38e24e178e76f2da100 (plain)
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
31
32
33
34
35
36
37
38
.DEFAULT_GOAL = test

include ../Makefile

testuser = testuser

SU = $(SUDO) su

.PHONY: test useradd cleanuser

useradd:
	$(SUDO) useradd $(testuser) --shell /bin/bash --create-home
	$(SU) - $(testuser) -c 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""'
	$(SU) - $(testuser) -c 'git config --global user.name $(testuser)'
	$(SU) - $(testuser) -c 'git config --global user.email $(testuser)'

test: $(shell getent passwd $(testuser) >/dev/null || echo useradd)
	$(ROOT_INSTALL) -t ~$(testuser) tests.sh
	$(SU) - $(testuser) -c ./tests.sh

ifeq ($(testuser),)
$(error testuser not defined)
endif
cleanuser_command = $(SUDO) rm -I -r ~$(testuser)

cleanuser:
	: Preparing to run destructive command:
	:
	:
	: 			$(cleanuser_command)
	:
	:
	: Press ctrl-c to abort.
	:
	@for n in 5 4 3 2 1; do printf '  %d\r' "$$n"; sleep 1; done
	$(cleanuser_command) || true
	$(SUDO) userdel testuser || true