From 96e5069514002ab53181820d4b1c0e28cee461d0 Mon Sep 17 00:00:00 2001 From: Joep van Delft Date: Fri, 15 Nov 2019 17:27:00 +0100 Subject: [PATCH] Brushing up --- .gitignore | 2 ++ .travis.yml | 1 + Makefile | 8 ++++++-- table | 12 ++++++++++++ table.1.rst | 2 +- test/runtests.sh | 6 +++--- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 10d00b5..5a119d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.gz +ngetopt.awk +test/*.out diff --git a/.travis.yml b/.travis.yml index f5ae071..564e85c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,3 @@ language: bash script: make test +after_failure: make show-failing-tests diff --git a/Makefile b/Makefile index 85f55a1..d29be6d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SHELL := /bin/bash +SHELL := /bin/bash -O nullglob .PHONY: test test: ngetopt.awk @@ -9,7 +9,7 @@ man: .ensure-rst2man.py table.1.gz libtable.2.gz .PHONY: ngetopt.awk ngetopt.awk: - gawk -i ngetopt 'BEGIN{exit}' || curl https://raw.githubusercontent.com/joepvd/ngetopt.awk/master/ngetopt.awk >ngetopt.awk + gawk -i ngetopt 'BEGIN{exit}' 2>/dev/null || curl -sSL https://raw.githubusercontent.com/joepvd/ngetopt.awk/master/ngetopt.awk >ngetopt.awk %.gz: %.rst rst2man.py $< | gzip >$@ @@ -17,3 +17,7 @@ ngetopt.awk: .PHONY: .ensure-rst2man.py .ensure-rst2man.py: @command -v rst2man.py >/dev/null + +.PHONY: show-failing-tests +show-failing-tests: + for f in test/*.out; do head $$f $${f/out}ok; done diff --git a/table b/table index f34bb47..e2374a5 100755 --- a/table +++ b/table @@ -15,11 +15,17 @@ @include "libtable" @include "walkarray" +function display_version( p) { + split(ENVIRON["_"], p, "/") + return sprintf("%s version %s", p[length(p)], "v0.3.0") +} + BEGIN { #opt_debug="y" regopt("short=s; long=style; flag=style; has_arg=yes; vals=rst|psql|md|jira; desc=Select output style.") regopt("short=d; long=debug; flag=debug; has_arg=no; desc=Output debugging stuff") regopt("short=h; long=help; flag=help; has_arg=no; desc=Show usage information") + regopt("short=v; long=version; flag=version; has_arg=no; desc=Show version information") regopt("short=F; long=field-separator; flag=FS; has_arg=yes; desc=Sets the field separator") regopt("short=R; long=record-separator; flag=RS; has_arg=yes; desc=Sets the record separator") regopt("short=H; long=no-header; flag=header; val=no; has_arg=no; desc=Disable header") @@ -33,7 +39,13 @@ BEGIN { parseopt(opt) + if (version == "yes") { + _assert_exit = 0 + print display_version() + exit + } if (help == "yes") { + print display_version() print usage() _assert_exit = 0 exit diff --git a/table.1.rst b/table.1.rst index cda86be..9e87148 100644 --- a/table.1.rst +++ b/table.1.rst @@ -9,7 +9,7 @@ Display text in a table :Author: joepvd :Date: 2015-03-29 :Copyright: GPLv2 -:Version: 0.2 +:Version: 0.3 :Manual section: 1 :Manual group: Text processing diff --git a/test/runtests.sh b/test/runtests.sh index 7a03d86..0d352ed 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # # Test script to run all the tests in the directory of the tests. One awk-file # where some command line options are defined shall be run for all tests in @@ -56,9 +56,9 @@ command rm -f *.out || exit 1 for testcase in *.test; do testname="${testcase%.*}" # Do the test. - sh "${testname}.test" >"${testname}.out" 2>&1 + bash "${testname}.test" >"${testname}.out" 2>&1 - if ! [[ -r "${testname}.ok" ]] + if ! [ -r "${testname}.ok" ] then fail "No output to compare to." continue