aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-03 13:12:33 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-03 13:12:33 +1200
commitfa1f90ab602989155aafb57fd2cf774791800b06 (patch)
tree4ebdad3eb8add37d961a778be50014bd81edb855
parentCorrect lint/bin directory (diff)
downloaddotfiles-fa1f90ab602989155aafb57fd2cf774791800b06.tar.gz
dotfiles-fa1f90ab602989155aafb57fd2cf774791800b06.zip
Add test to check binscripts match manpages
-rw-r--r--Makefile5
-rwxr-xr-xtest/man45
2 files changed, 49 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index c863b17a..3f579764 100644
--- a/Makefile
+++ b/Makefile
@@ -316,7 +316,7 @@ install-zsh :
install -pm 0644 -- zsh/zprofile "$(HOME)"/.zprofile
install -pm 0644 -- zsh/zshrc "$(HOME)"/.zshrc
-test : test-bash test-bin test-games test-sh test-urxvt
+test : test-bash test-bin test-games test-man test-sh test-urxvt
test-bash :
test/bash
@@ -327,6 +327,9 @@ test-bin :
test-games :
test/games
+test-man :
+ test/man
+
test-sh :
test/sh
diff --git a/test/man b/test/man
new file mode 100755
index 00000000..299fa60f
--- /dev/null
+++ b/test/man
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Check that manual pages and logical binaries match up
+
+# Need some scripts from the source directory
+PATH=bin:$PATH
+
+# Create temporary directory and implement cleanup function for it
+td=
+cleanup() {
+ rm -fr -- "$td"
+}
+for sig in EXIT HUP INT TERM ; do
+ trap cleanup "$sig"
+done
+td=$(mktd test-man) || exit
+
+# Get lists of logical binaries and manual pages
+for dir in bin games ; do (
+ cd -- "$dir"
+ pa *
+) done | sort | sed 's/\...*$//' > "$td"/bin
+for dir in man/man[168] ; do (
+ cd -- "$dir"
+ pa *.[168]
+) done | sort | sed 's/\.[168]$//' > "$td"/man
+
+# Get lists of noman scripts and nobin manual pages
+comm -23 "$td"/bin "$td"/man > "$td"/noman
+comm -13 "$td"/bin "$td"/man > "$td"/nobin
+
+# Emit the content of both, if any
+ex=0
+if [ -s "$td"/noman ] ; then
+ printf >&2 '%s\n' 'No manual pages found for:'
+ cat >&2 -- "$td"/noman
+ ex=1
+fi
+if [ -s "$td"/nobin ] ; then
+ printf >&2 '%s\n' 'Stray manual page for:'
+ cat >&2 -- "$td"/nobin
+ ex=1
+fi
+
+# Exit appropriately
+exit "$ex"