From 585f4df8df70f8899d1b1b7c12461ddf12ef1076 Mon Sep 17 00:00:00 2001 From: gravel Date: Fri, 27 Jan 2023 11:35:29 +0100 Subject: [PATCH] Add tests to Makefile --- Makefile | 63 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 82b4f2e6..09c6de4d 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,71 @@ -# First goal is always run with just `make` -all: - /bin/php php/update-listing.php +port = 8080 +output = output -data: +# First goal is the default with `make`. + +# List make scripts. +list: + grep "^[^[:space:]]*:" Makefile --before-context=1 --group-separator="" + +## Using make dependencies is duplicating behaviour but reads better. +# /bin/php php/update-listing.php +# Refresh listing and generate HTML. +all: fetch html + +# Fetch room listing. +fetch: /bin/php php/fetch-servers.php +# Generate HTML from data. html: /bin/php php/generate-html.php -dev: - xdg-open http://localhost:8080 +# Last item run in foreground to receive interrupts. + +# Serve a local copy which responds to file changes. +dev: open make server & make watchdog -lan-dev: +# Serve a local copy on LAN which responds to file changes. +lan-dev: open ip addr | fgrep -e ' 192.' -e ' 10.' - xdg-open http://localhost:8080 make lan-server & make watchdog +# Serve a local copy. server: - /bin/php -S localhost:8080 -t output + /bin/php -S localhost:$(port) -t $(output) +# Serve a local copy on all interfaces. lan-server: - /bin/php -S 0.0.0.0:8080 -t output + /bin/php -S 0.0.0.0:$(port) -t $(output) + +# Open locally served page in browser. +open: + xdg-open http://localhost:$(port) >/dev/null 2>/dev/null & disown -# Update html on file change -# Doesn't check for new files +# Update HTML on file change. Doesn't check for new files. watchdog: find . | entr -n -s "make html" +# Remove artefacts +clean: + rm -r cache + rm -r output/*.html + +# Build everything from scratch and test functionality. +test: clean all open server + +# Build everything from scratch and test functionality on LAN. +test-lan: clean all open lan-server + +# -- Aliases -- +serve: server + +lan-serve: lan-server + +data: fetch + +watch: watchdog +