diff options
Diffstat (limited to 'tests.makefile')
-rw-r--r-- | tests.makefile | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests.makefile b/tests.makefile new file mode 100644 index 0000000..b152f01 --- /dev/null +++ b/tests.makefile | |||
@@ -0,0 +1,34 @@ | |||
1 | testuser = testuser | ||
2 | |||
3 | SU = $(SUDO) su | ||
4 | |||
5 | .PHONY: test useradd cleanuser | ||
6 | |||
7 | useradd: | ||
8 | $(SUDO) useradd $(testuser) --shell /bin/bash --create-home | ||
9 | $(SU) - $(testuser) -c 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""' | ||
10 | $(SU) - $(testuser) -c 'git config --global user.name $(testuser)' | ||
11 | $(SU) - $(testuser) -c 'git config --global user.email $(testuser)' | ||
12 | |||
13 | test: install $(shell getent passwd $(testuser) >/dev/null || echo useradd) | ||
14 | $(ROOT_INSTALL) -t ~$(testuser) tests.sh | ||
15 | $(SU) - $(testuser) -c ./tests.sh | ||
16 | |||
17 | ifeq ($(testuser),) | ||
18 | $(error testuser not defined) | ||
19 | endif | ||
20 | cleanuser_command = $(SUDO) rm -I -r ~$(testuser) | ||
21 | |||
22 | cleanuser: | ||
23 | : Preparing to run destructive command: | ||
24 | : | ||
25 | : | ||
26 | : $(cleanuser_command) | ||
27 | : | ||
28 | : | ||
29 | : Press ctrl-c to abort. | ||
30 | : | ||
31 | @for n in 5 4 3 2 1; do printf ' %d\r' "$$n"; sleep 1; done | ||
32 | $(cleanuser_command) || true | ||
33 | $(SUDO) userdel testuser || true | ||
34 | |||