Don't use non existing myerror()
[lunit.git] / lunit
blobac5e9a1f538843fb0c81de56e61899b201971931
1 #! /bin/sh
3 # This file is part of lunit 0.4.
5 # For Details about lunit look at: http://www.mroth.net/lunit/
7 # Author: Michael Roth <mroth@nessie.de>
9 # Copyright (c) 2004-2009 Michael Roth <mroth@nessie.de>
11 # Permission is hereby granted, free of charge, to any person
12 # obtaining a copy of this software and associated documentation
13 # files (the "Software"), to deal in the Software without restriction,
14 # including without limitation the rights to use, copy, modify, merge,
15 # publish, distribute, sublicense, and/or sell copies of the Software,
16 # and to permit persons to whom the Software is furnished to do so,
17 # subject to the following conditions:
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 if test $# = 0 ; then
32 echo "$0: Usage Error. Try $0 --help" >&2
33 exit 1
36 scriptname="$(readlink -n -f "$0")"
37 interpreter="lua"
38 options=""
40 while true ; do
41 case "$1" in
42 -h|--help)
43 cat <<EOT
44 lunit 0.4
45 Copyright (c) 2004-2008 Michael Roth <mroth@nessie.de>
46 This program comes WITHOUT WARRANTY OF ANY KIND.
48 Usage: lunit [OPTIONS] [--] scripts
50 Options:
52 -i, --interpreter LUA Complete path of the lua binary to use.
53 -p, --path PATH Sets the LUA_PATH environment for the tests.
54 --cpath CPATH Sets the LUA_CPATH environment for the tests.
55 -r, --runner RUNNER Testrunner to use, defaults to 'lunit-console'.
56 -t, --test PATTERN Which tests to run, may contain * or ? wildcards.
57 --loadonly Only load the tests.
58 --dontforce Do not force to load $scriptname*.lua.
59 -h, --help Print this help screen.
60 --version Print lunit version.
62 Please report bugs to <mroth@nessie.de>.
63 EOT
64 exit ;;
66 --version)
67 echo "lunit 0.4pre Copyright 2004-2008 Michael Roth <mroth@nessie.de>" # FIXME
68 exit ;;
70 -i|--interpreter)
71 interpreter="$2"
72 shift 2 ;;
74 -p|--path)
75 LUA_PATH="$2"
76 export LUA_PATH
77 shift 2 ;;
79 --cpath)
80 LUA_CPATH="$2"
81 export LUA_CPATH
82 shift 2 ;;
84 --loadonly)
85 options="$options $1"
86 shift 1 ;;
88 --dontforce)
89 scriptname=""
90 shift 1 ;;
92 -r|--runner|-t|--test)
93 options="$options $1 $2"
94 shift 2 ;;
96 --)
97 break ;;
99 -*)
100 echo "$0: Invalid option: $1" >&2
101 exit 1 ;;
104 break ;;
105 esac
106 done
109 exec "$interpreter" - "$scriptname" $options "$@" <<EOT
110 local scriptname = ...
111 local argv = { select(2,...) }
112 if scriptname ~= "" then
113 local function force(name)
114 pcall( function() loadfile(name)() end )
116 force( scriptname..".lua" )
117 force( scriptname.."-console.lua" )
119 require "lunit"
120 local stats = lunit.main(argv)
121 if stats.errors > 0 or stats.failed > 0 then
122 os.exit(1)