From 2f5c3f189d83b6297a93dee83819092a63a33e88 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 16 Aug 2016 14:24:31 +1200 Subject: Rename "test" targets to "check" Mostly to make way for an actual test suite beyond mere syntax checking --- Makefile | 54 +++++++++++++++++++++++++++--------------------------- README.markdown | 7 ++++--- check/bash | 6 ++++++ check/bin | 14 ++++++++++++++ check/games | 14 ++++++++++++++ check/man | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ check/pdksh | 6 ++++++ check/sh | 6 ++++++ check/urxvt | 6 ++++++ test/bash | 6 ------ test/bin | 14 -------------- test/games | 14 -------------- test/man | 49 ------------------------------------------------- test/pdksh | 6 ------ test/sh | 6 ------ test/urxvt | 6 ------ 16 files changed, 132 insertions(+), 131 deletions(-) create mode 100755 check/bash create mode 100755 check/bin create mode 100755 check/games create mode 100755 check/man create mode 100755 check/pdksh create mode 100755 check/sh create mode 100755 check/urxvt delete mode 100755 test/bash delete mode 100755 test/bin delete mode 100755 test/games delete mode 100755 test/man delete mode 100755 test/pdksh delete mode 100755 test/sh delete mode 100755 test/urxvt diff --git a/Makefile b/Makefile index 3e08bb0a..3c52034f 100644 --- a/Makefile +++ b/Makefile @@ -42,12 +42,12 @@ install-wyrd \ install-x \ install-zsh \ - test \ - test-bash \ - test-bin \ - test-games \ - test-sh \ - test-urxvt \ + check \ + check-bash \ + check-bin \ + check-games \ + check-sh \ + check-urxvt \ lint \ lint-bash \ lint-bin \ @@ -144,7 +144,7 @@ install-abook : "$(HOME)"/.abook install -pm 0644 -- abook/abookrc "$(HOME)"/.abook -install-bash : test-bash +install-bash : check-bash install -m 0755 -d -- \ "$(HOME)"/.config \ "$(HOME)"/.bashrc.d \ @@ -160,7 +160,7 @@ install-bash-completion : install-bash install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d -install-bin : bin/sd2u bin/su2d bin/unf test-bin install-bin-man +install-bin : bin/sd2u bin/su2d bin/unf check-bin install-bin-man install -m 0755 -d -- "$(HOME)"/.local/bin for name in bin/* ; do \ [ -x "$$name" ] || continue ; \ @@ -193,7 +193,7 @@ install-finger : install -pm 0644 -- finger/project "$(HOME)"/.project install -pm 0644 -- finger/pgpkey "$(HOME)"/.pgpkey -install-games : games/acq games/kvlt games/zs test-games install-games-man +install-games : games/acq games/kvlt games/zs check-games install-games-man install -m 0755 -d -- "$(HOME)"/.local/games for name in games/* ; do \ [ -x "$$name" ] || continue ; \ @@ -225,7 +225,7 @@ install-i3 : install-x install -m 0755 -d -- "$(HOME)"/.i3 install -pm 0644 -- i3/* "$(HOME)"/.i3 -install-pdksh : test-pdksh install-sh +install-pdksh : check-pdksh install-sh install -m 0755 -d -- \ "$(HOME)"/.pdkshrc.d install -pm 0644 -- pdksh/pdkshrc "$(HOME)"/.pdkshrc @@ -272,7 +272,7 @@ install-psql : install-readline : install -pm 0644 -- readline/inputrc "$(HOME)"/.inputrc -install-sh : test-sh +install-sh : check-sh install -m 0755 -d -- "$(HOME)"/.profile.d install -pm 0644 -- sh/profile "$(HOME)"/.profile install -pm 0644 -- sh/profile.d/* "$(HOME)"/.profile.d @@ -290,7 +290,7 @@ install-terminfo : install-tmux : tmux/tmux.conf install -pm 0644 -- tmux/tmux.conf "$(HOME)"/.tmux.conf -install-urxvt : test-urxvt +install-urxvt : check-urxvt install -m 0755 -d -- "$(HOME)"/.urxvt/ext install -m 0755 -- urxvt/ext/* "$(HOME)"/.urxvt/ext @@ -337,28 +337,28 @@ install-zsh : install -pm 0644 -- zsh/zprofile "$(HOME)"/.zprofile install -pm 0644 -- zsh/zshrc "$(HOME)"/.zshrc -test : test-bash test-bin test-games test-man test-sh test-urxvt +check : check-bash check-bin check-games check-man check-sh check-urxvt -test-bash : - test/bash +check-bash : + check/bash -test-bin : - test/bin +check-bin : + check/bin -test-games : - test/games +check-games : + check/games -test-pdksh : - test/pdksh +check-pdksh : + check/pdksh -test-man : - test/man +check-man : + check/man -test-sh : - test/sh +check-sh : + check/sh -test-urxvt : - test/urxvt +check-urxvt : + check/urxvt lint : lint-bash lint-bin lint-games lint-sh lint-urxvt diff --git a/README.markdown b/README.markdown index f7c75d88..74a3cc44 100644 --- a/README.markdown +++ b/README.markdown @@ -423,9 +423,10 @@ your `/etc/manpath` configuration, depending on your system. Testing ------- -You can test that both sets of shell scripts are syntactically correct with -`make test-bash`, `make test-sh`, or `make test` for everything including the -scripts in `bin` and `games`. +You can check that both sets of shell scripts are syntactically correct with +`make check-bash`, `make check-sh`, or `make check` for everything including +the scripts in `bin` and `games`. There's no proper test suite for the actual +functionality (yet). If you have [ShellCheck](https://www.shellcheck.net/) and/or [Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell diff --git a/check/bash b/check/bash new file mode 100755 index 00000000..f203c2c1 --- /dev/null +++ b/check/bash @@ -0,0 +1,6 @@ +#!/bin/sh +for bash in bash/* bash/bashrc.d/* bash/bash_profile.d/* ; do + [ -f "$bash" ] || continue + bash -n "$bash" || exit +done +printf 'All bash(1) scripts parsed successfully.\n' diff --git a/check/bin b/check/bin new file mode 100755 index 00000000..a4d5e452 --- /dev/null +++ b/check/bin @@ -0,0 +1,14 @@ +#!/bin/sh +for bin in bin/* ; do + [ -f "$bin" ] || continue + hb=$(sed 1q "$bin") || exit + case $hb in + *bash) + bash -n "$bin" || exit + ;; + *sh) + sh -n "$bin" || exit + ;; + esac +done +printf 'All shell scripts in bin parsed successfully.\n' diff --git a/check/games b/check/games new file mode 100755 index 00000000..3afe6414 --- /dev/null +++ b/check/games @@ -0,0 +1,14 @@ +#!/bin/sh +for game in games/* ; do + [ -f "$game" ] || continue + hb=$(sed 1q "$game") || exit + case $hb in + *bash) + bash -n "$game" || exit + ;; + *sh) + sh -n "$game" || exit + ;; + esac +done +printf 'All shell scripts in games parsed successfully.\n' diff --git a/check/man b/check/man new file mode 100755 index 00000000..4b5a7831 --- /dev/null +++ b/check/man @@ -0,0 +1,49 @@ +#!/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 | +sed 's/\...*$//' | +sort | uniq > "$td"/bin +for dir in man/man[168] ; do ( + cd -- "$dir" + pa *.[168] +) done | +sed 's/\.[168]$//' | +sort | uniq > "$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" diff --git a/check/pdksh b/check/pdksh new file mode 100755 index 00000000..fd1d55b7 --- /dev/null +++ b/check/pdksh @@ -0,0 +1,6 @@ +#!/bin/sh +for pdksh in pdksh/* pdksh/pdkshrc.d/* ; do + [ -f "$pdksh" ] || continue + ksh -n "$pdksh" || exit +done +printf 'All pdksh scripts parsed successfully.\n' diff --git a/check/sh b/check/sh new file mode 100755 index 00000000..47e41c77 --- /dev/null +++ b/check/sh @@ -0,0 +1,6 @@ +#!/bin/sh +for sh in sh/* sh/profile.d/* ; do + [ -f "$sh" ] || continue + sh -n "$sh" || exit +done +printf 'All sh(1) scripts parsed successfully.\n' diff --git a/check/urxvt b/check/urxvt new file mode 100755 index 00000000..d27d6660 --- /dev/null +++ b/check/urxvt @@ -0,0 +1,6 @@ +#!/bin/sh +for perl in urxvt/ext/* ; do + [ -f "$perl" ] || continue + perl -c "$perl" >/dev/null || exit +done +printf 'All Perl scripts in urxvt/ext parsed successfully.\n' diff --git a/test/bash b/test/bash deleted file mode 100755 index f203c2c1..00000000 --- a/test/bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for bash in bash/* bash/bashrc.d/* bash/bash_profile.d/* ; do - [ -f "$bash" ] || continue - bash -n "$bash" || exit -done -printf 'All bash(1) scripts parsed successfully.\n' diff --git a/test/bin b/test/bin deleted file mode 100755 index a4d5e452..00000000 --- a/test/bin +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for bin in bin/* ; do - [ -f "$bin" ] || continue - hb=$(sed 1q "$bin") || exit - case $hb in - *bash) - bash -n "$bin" || exit - ;; - *sh) - sh -n "$bin" || exit - ;; - esac -done -printf 'All shell scripts in bin parsed successfully.\n' diff --git a/test/games b/test/games deleted file mode 100755 index 3afe6414..00000000 --- a/test/games +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for game in games/* ; do - [ -f "$game" ] || continue - hb=$(sed 1q "$game") || exit - case $hb in - *bash) - bash -n "$game" || exit - ;; - *sh) - sh -n "$game" || exit - ;; - esac -done -printf 'All shell scripts in games parsed successfully.\n' diff --git a/test/man b/test/man deleted file mode 100755 index 4b5a7831..00000000 --- a/test/man +++ /dev/null @@ -1,49 +0,0 @@ -#!/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 | -sed 's/\...*$//' | -sort | uniq > "$td"/bin -for dir in man/man[168] ; do ( - cd -- "$dir" - pa *.[168] -) done | -sed 's/\.[168]$//' | -sort | uniq > "$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" diff --git a/test/pdksh b/test/pdksh deleted file mode 100755 index fd1d55b7..00000000 --- a/test/pdksh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for pdksh in pdksh/* pdksh/pdkshrc.d/* ; do - [ -f "$pdksh" ] || continue - ksh -n "$pdksh" || exit -done -printf 'All pdksh scripts parsed successfully.\n' diff --git a/test/sh b/test/sh deleted file mode 100755 index 47e41c77..00000000 --- a/test/sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for sh in sh/* sh/profile.d/* ; do - [ -f "$sh" ] || continue - sh -n "$sh" || exit -done -printf 'All sh(1) scripts parsed successfully.\n' diff --git a/test/urxvt b/test/urxvt deleted file mode 100755 index d27d6660..00000000 --- a/test/urxvt +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for perl in urxvt/ext/* ; do - [ -f "$perl" ] || continue - perl -c "$perl" >/dev/null || exit -done -printf 'All Perl scripts in urxvt/ext parsed successfully.\n' -- cgit v1.2.3