ly/: Create one .ly file for every .ily instrument file
[sunny256-utils.git] / run-test
blob2894c9c533b65d65ee70d4f2cd6fceaa9df3c7ba
1 #!/usr/bin/env bash
3 #==============================================================================
4 # run-test
5 # File ID: a813eb74-2b2c-11e5-b0b2-000df06acc56
7 # Execute a test file and show the first failing test in vimdiff.
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=run-test
14 VERSION=0.3.0
16 ARGS="$(getopt -o "\
21 " -l "\
22 help,\
23 quiet,\
24 verbose,\
25 version,\
26 " -n "$progname" -- "$@")"
27 test "$?" = "0" || exit 1
28 eval set -- "$ARGS"
30 opt_diff=0
31 opt_help=0
32 opt_quiet=0
33 opt_verbose=0
34 while :; do
35 case "$1" in
36 -d|--diff) opt_diff=1; shift ;;
37 -h|--help) opt_help=1; shift ;;
38 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
39 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
40 --version) echo $progname $VERSION; exit 0 ;;
41 --) shift; break ;;
42 *) echo $progname: Internal error >&2; exit 1 ;;
43 esac
44 done
45 opt_verbose=$(($opt_verbose - $opt_quiet))
47 if test "$opt_help" = "1"; then
48 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
49 cat <<END
51 Execute a test file and show the first failing test in vimdiff.
53 Usage: $progname [options] TESTFILE
55 Options:
57 -d, --diff
58 Show a regular textual diff instead of starting vimdiff.
59 -h, --help
60 Show this help.
61 -q, --quiet
62 Be more quiet. Can be repeated to increase silence.
63 -v, --verbose
64 Increase level of verbosity. Can be repeated.
65 --version
66 Print version information.
68 END
69 exit 0
72 script="$1"
73 shift
74 "$script" 2>&1 | gotexp "$@"
75 if test "$opt_diff" = "1"; then
76 diff -u exp got
77 else
78 vimdiff -c "windo set wrap" exp got
80 rm got exp
82 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :