Skip to content

Commit

Permalink
Brushing up
Browse files Browse the repository at this point in the history
  • Loading branch information
joepvd committed Nov 15, 2019
1 parent 6b708d7 commit 96e5069
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.gz
ngetopt.awk
test/*.out
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
language: bash
script: make test
after_failure: make show-failing-tests
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHELL := /bin/bash
SHELL := /bin/bash -O nullglob

.PHONY: test
test: ngetopt.awk
Expand All @@ -9,11 +9,15 @@ 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 >$@

.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
12 changes: 12 additions & 0 deletions table
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion table.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/runtests.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96e5069

Please sign in to comment.