From: Andre Noll Date: Sun, 11 May 2014 10:19:12 +0000 (+0200) Subject: Merge branch 't/test_man' X-Git-Tag: v0.5.3~21 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=d1e6b28f66e243516d01916f9125baee75dd98d6;hp=bfdd36f2879b8dee1f6d3330bc49fbb5644d3caf Merge branch 't/test_man' Cooking since 2014-03-16. * t/test_man: test-lib: Make colors work on FreeBSD. test suite: Add sanity check for generated man pages. --- diff --git a/NEWS b/NEWS index 7cf5dca2..4da56905 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ NEWS ------------------------------------------------- - Various alsa-related fixes, mostly for the raspberry pi. + - The test suite has been extended to include sanity checks + for the generated man pages. ---------------------------------------- 0.5.2 (2014-04-11) "orthogonal interior" diff --git a/t/makefile.test b/t/makefile.test index a2bd4e53..6ef9ac84 100644 --- a/t/makefile.test +++ b/t/makefile.test @@ -8,6 +8,7 @@ test_options += --results-dir $(results_dir) test_options += --trash-dir $(trash_dir) test_options += --executables "$(prefixed_executables)" test_options += --objects "$(basename $(all_objs))" +test_options += --man-dir $(man_dir) ifdef V ifeq ("$(origin V)", "command line") diff --git a/t/t0005-man.sh b/t/t0005-man.sh new file mode 100755 index 00000000..7a627aad --- /dev/null +++ b/t/t0005-man.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +test_description='Parse generated man pages. + +Simple sanity checks of some man pages. + +* para_audiod: Check that list of audiod commands is present +* para_server: Check that list of server/afs commands is present +* para_play: Check that list of play commands is present + +* para_{recv,filter,write,audiod}: Check for presence of +filter/receiver/writer options as appropriate ' + +. ${0%/*}/test-lib.sh + +rfw_regex='Options for .\{100,\}Options for ' # recv/filter/writer + +grep_man() +{ + local regex="$1" exe="$2" + tr '\n' ' ' < "$o_man_dir/para_$exe.1" | grep -q "$regex" +} + +# check that options of all reveivers/filters/writers are contained +# in the man pages + +regex="$rfw_regex" +test_expect_success 'para_recv: receiver options' "grep_man '$regex' recv" +test_expect_success 'para_filter: filter options' "grep_man '$regex' filter" +test_expect_success 'para_write: writer options' "grep_man '$regex' write" +test_require_objects "audiod" +if [[ -n "$result" ]]; then + test_skip 'para_audiod' "missing object(s): $result" +else + test_expect_success 'para_audiod: recv/filter/writer options' \ + "grep_man '$regex' audiod" +fi + +# check various command lists + +test_require_objects "audiod" +if [[ -n "$result" ]]; then + test_skip 'para_audiod' "missing object(s): $result" +else + regex='LIST OF AUDIOD COMMANDS.\{200,\}' + test_expect_success 'para_audiod: command list' \ + "grep_man '$regex' audiod" +fi + +test_require_objects "server" +missing_objects="$result" +if [[ -n "$missing_objects" ]]; then + test_skip "para_server" "missing object(s): $missing_objects" +else + regex='LIST OF SERVER COMMANDS.\{100,\}LIST OF AFS COMMANDS' + test_expect_success 'para_server: server/afs commands' \ + "grep_man '$regex' server" +fi + +# para_play is always built +regex='LIST OF COMMANDS.\{100,\}' +test_expect_success 'para_play: play commands' "grep_man '$regex' play" +regex="$rfw_regex" +test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index f1bb8cf6..0e702b53 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -21,22 +21,22 @@ say_color() if [[ "$o_nocolor" != "true" && -n "$1" ]]; then export TERM=$ORIGINAL_TERM case "$1" in - error) tput bold; tput setaf 1;; - skip) tput setaf 5;; + error) tput $C_BOLD; tput $C_SETAF 1;; + skip) tput $C_SETAF 5;; ok) (($o_verbose == 0)) && return - tput setaf 2;; - pass) tput bold; tput setaf 2;; - info) tput setaf 3;; + tput $C_SETAF 2;; + pass) tput $C_BOLD; tput $C_SETAF 2;; + info) tput $C_SETAF 3;; run) (($o_verbose == 0)) && return - tput setaf 6;; + tput $C_SETAF 6;; esac fi shift printf "%s\n" "$*" if [[ "$o_nocolor" != "true" && -n "$1" ]]; then - tput sgr0 + tput $C_SGR0 export TERM=dumb fi } @@ -218,9 +218,21 @@ can_use_colors() result="false" [[ "$TERM" == "dumb" ]] && return [[ -t 1 ]] || return - tput bold >/dev/null 2>&1 || return - tput setaf 1 >/dev/null 2>&1 || return - tput sgr0 >/dev/null 2>&1 || return + C_BOLD='bold' + tput $C_BOLD &>/dev/null || { + C_BOLD='md' + tput $C_BOLD &>/dev/null + } || return + C_SETAF='setaf' + tput $C_SETAF 1 &>/dev/null || { + C_SETAF='AF' + tput $C_SETAF 1 &>/dev/null + } || return + C_SGR0='sgr0' + tput $C_SGR0 >/dev/null 2>&1 || { + C_SGR0='me' + tput $C_SGR0 &>/dev/null + } || return result="true" } @@ -235,6 +247,7 @@ parse_options() -v=1|--verbose=1) o_verbose="1"; shift;; -v|--verbose|-v=2|--verbose=2) o_verbose="2"; shift;; --no-color) o_nocolor="true"; shift;; + --man-dir) export o_man_dir="$2"; shift; shift;; --results-dir) o_results_dir="$2"; shift; shift;; --trash-dir) o_trash_dir="$2"; shift; shift;; --executables-dir) export o_executables_dir="$2"; shift; shift;; @@ -265,11 +278,13 @@ fixup_dirs() [[ -z "$o_results_dir" ]] && o_results_dir="$test_dir/test-results" [[ -z "$o_executables_dir" ]] && o_executables_dir="$test_dir/.." [[ -z "$o_trash_dir" ]] && o_trash_dir="$test_dir/trashes" + [[ -z "$o_man_dir" ]] && o_man_dir="$test_dir/../build/man/man1" # we want alsolute paths because relative paths become invalid # after changing to the trash dir [[ -n "${o_results_dir##/*}" ]] && o_results_dir="$wd/$o_results_dir" [[ -n "${o_executables_dir##/*}" ]] && o_executables_dir="$wd/$o_results_dir" + [[ -n "${o_man_dir##/*}" ]] && o_man_dir="$wd/$o_man_dir" [[ -n "${o_trash_dir##/*}" ]] && o_trash_dir="$wd/$o_trash_dir" mkdir -p "$o_results_dir"