blob: d6e7fa16466cd7f05d3b47bfc3cf310cd7ef24b3 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# Makefile for archsetup
# VM-based integration testing + project dependencies.
#
# Dotfile stow operations live in the dotfiles repo's own Makefile
# (https://git.cjennings.net/dotfiles.git). Run them from there:
# cd ~/.dotfiles && make stow|restow|reset|unstow|import <de>
.PHONY: help deps test-unit test test-keep test-vm-base package-diff
# Filesystem profile for the VM harness: btrfs (default) or zfs. Selects the
# base image the scripts build/use; exported so create-base-vm.sh + run-test.sh
# pick the matching archangel config and image. e.g. make test FS_PROFILE=zfs
FS_PROFILE ?= btrfs
export FS_PROFILE
ifeq ($(FS_PROFILE),btrfs)
BASE_IMAGE := vm-images/archsetup-base.qcow2
else
BASE_IMAGE := vm-images/archsetup-base-$(FS_PROFILE).qcow2
endif
# Default target - show help
help:
@echo "archsetup - install and test"
@echo ""
@echo "Targets:"
@echo " deps Install VM-testing dependencies"
@echo " test-unit Run fast unit tests for installer helpers (no VM)"
@echo " test Run full VM test suite (creates base VM if needed)"
@echo " test-keep Run test and keep VM running for manual testing"
@echo " test-vm-base Create base VM only (runs archangel)"
@echo " package-diff Compare archsetup's declared packages vs this system"
@echo ""
@echo "Filesystem profile (test, test-keep, test-vm-base):"
@echo " FS_PROFILE=btrfs (default) or zfs, e.g. make test FS_PROFILE=zfs"
@echo ""
@echo "Dotfile stow operations now live in the dotfiles repo:"
@echo " cd ~/.dotfiles && make stow|restow|reset|unstow|import <de>"
@echo ""
# Install project dependencies (VM integration testing)
deps:
@echo "Installing VM testing dependencies..."
sudo pacman -S --needed qemu-full virt-manager virt-viewer libguestfs \
bridge-utils dnsmasq archiso sshpass socat \
python-pytest python-pytest-testinfra
@echo ""
@echo "Done. For VM testing, also ensure libvirtd is running:"
@echo " sudo systemctl enable --now libvirtd"
# Run the fast unit-test suites for installer helpers (no VM needed).
# One suite per tests/<name>/ dir; `unittest discover` can't find them
# because the dir names are hyphenated, so each suite is run explicitly.
test-unit:
@fail=0; \
for t in tests/*/test_*.py; do \
mod=$$(echo "$$t" | sed 's|/|.|g; s|\.py$$||'); \
echo "==> $$mod"; \
python3 -m unittest "$$mod" || fail=1; \
done; \
exit $$fail
# Create base VM for testing (runs archangel only, no archsetup)
test-vm-base:
@bash scripts/testing/create-base-vm.sh
# Test - run full VM integration test suite (creates base VM if needed)
test:
@if [ ! -f $(BASE_IMAGE) ] || \
! qemu-img snapshot -l $(BASE_IMAGE) 2>/dev/null | grep -q "clean-install"; then \
echo "Base VM not found or missing snapshot, creating ($(FS_PROFILE))..."; \
bash scripts/testing/create-base-vm.sh; \
fi
@bash scripts/testing/run-test.sh
# Test and keep VM running (for manual testing after archsetup)
test-keep:
@if [ ! -f $(BASE_IMAGE) ] || \
! qemu-img snapshot -l $(BASE_IMAGE) 2>/dev/null | grep -q "clean-install"; then \
echo "Base VM not found or missing snapshot, creating ($(FS_PROFILE))..."; \
bash scripts/testing/create-base-vm.sh; \
fi
@bash scripts/testing/run-test.sh --keep
# Compare the packages archsetup declares against what's installed here.
# Shows declared-but-missing and installed-but-undeclared (AUR vs official).
package-diff:
@bash scripts/package-inventory
|