From b1e5c752955ce474a54dd240f19a1836d741d07a Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Sun, 11 Feb 2024 23:20:28 -0500 Subject: [PATCH 1/2] Use `/bin/echo` in tests rather than shell builtin --- README.md | 6 +++--- config.mk | 4 ++++ test/Makefile | 14 +++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dd9329f..0f72151 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ There is a simple test harness which can be invoked via `make test`. If you wish to port this software to an untested platform the tests will greatly assist in that process. > Note: if your OS uses **dash** as `/bin/sh` then the builtin echo command will not -> be up to the task of printing the escape sequences used by the test runner. If this -> bothers you, you can call `make` with the `SHELL` environment variable overridden -> by calling `make SHELL=/bin/bash all test`. +> be up to the task of printing the escape sequences used by the test runner. In +> this case, be sure to set the `ECHO` variable to `/bin/echo` in the *config.mk* +> file. ## Contributing Contributions are always welcome and can be made via pull request or `git send-email`, diff --git a/config.mk b/config.mk index 5906546..f89317e 100644 --- a/config.mk +++ b/config.mk @@ -5,6 +5,10 @@ libdir = $(DESTDIR)$(PREFIX)/lib sharedir = $(DESTDIR)$(PREFIX)/share mandir = $(sharedir)/man docdir = $(sharedir)/doc/haggis +# We need an `echo` program that doesn't screw with terminal escape sequences. +# This only matters if /bin/sh is a symlink to dash, as the echo builtin in dash +# will screw with them and pass them as printed characters. +ECHO = /bin/echo # Comment this line if your OS ships libmd as part of libc # (NetBSD, OpenBSD) LIBS += -lmd diff --git a/test/Makefile b/test/Makefile index 1b492c1..798a2ff 100644 --- a/test/Makefile +++ b/test/Makefile @@ -82,24 +82,24 @@ total != echo $(tests) | wc -w | awk '{ print $$1 }' .PHONY: test test: $(tests) output - @echo -e "\n\t=== \e[0;33mRunning $(total) tests\e[0m ===\n" + @$(ECHO) -e "\n\t=== \e[0;33mRunning $(total) tests\e[0m ===\n" @idx=1 ; success=0 ; fail=0; skip=0; for t in $(tests) ; \ do printf "[%02i/$(total)] %-25s" $${idx} $${t} ; \ idx=$$(expr $${idx} + 1) ; \ ./$${t} ; \ retval=$$? ; \ if [ $${retval} -eq 0 ] ; \ - then echo -e '\e[0;32mSuccess\e[0m' ; \ + then $(ECHO) -e '\e[0;32mSuccess\e[0m' ; \ success=$$(expr $${success} + 1) ; \ elif [ $${retval} -eq 255 ] ; \ - then echo Skipped ; \ + then $(ECHO) Skipped ; \ skip=$$(expr $${skip} + 1) ; \ - else echo -e '\e[0;31mFailure\e[0m' ; \ + else $(ECHO) -e '\e[0;31mFailure\e[0m' ; \ fail=$$(expr $${fail} + 1) ; \ fi ; done || true ; \ - if [ $${fail} == 0 ] ; \ - then echo -e '\nResults: \e[0;32mOk\e[0m.' "$${success} succeeded; $${fail} failed; $${skip} skipped" ; \ - else echo -e '\nResults: \e[0;31mFAILED\e[0m.' "$${success} succeeded; $${fail} failed; $${skip} skipped" ; \ + if [ $${fail} -eq 0 ] ; \ + then $(ECHO) -e '\nResults: \e[0;32mOk\e[0m.' "$${success} succeeded; $${fail} failed; $${skip} skipped" ; \ + else $(ECHO) -e '\nResults: \e[0;31mFAILED\e[0m.' "$${success} succeeded; $${fail} failed; $${skip} skipped" ; \ fi output: From 2cd69710d755bdb9b8413368072c7a5f87ddc10b Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 21 Mar 2024 23:29:20 -0400 Subject: [PATCH 2/2] Move config.mk to config.mk.in and add config.mk to .gitignore --- .gitignore | 2 ++ config.mk => config.mk.in | 0 2 files changed, 2 insertions(+) rename config.mk => config.mk.in (100%) diff --git a/.gitignore b/.gitignore index 3e085f3..bce5baa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ test/* *.a *.so *.core +config.mk + diff --git a/config.mk b/config.mk.in similarity index 100% rename from config.mk rename to config.mk.in