File: test.hello_world_error

package info (click to toggle)
shellia 5.7.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 728 kB
  • sloc: sh: 7,087; makefile: 34
file content (75 lines) | stat: -rwxr-xr-x 2,736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# vim: set filetype=sh :
#        file: test.hello_world_error
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
#     license: GNU General Public License, version 3
# description: test simple script like "hello world" but with functions
#    see also: hello_world_error

# The following tests are included:
# (1) Run without options
# (2) Run interactive

. ./tstlib

shell=""
while [ $# -ne 0 ]; do
  if [ "$1" = "-s" ]; then
    shell="$2"
    shift 2
  else
    /bin/echo "ERROR $0: unknown option <$1>" >&2
    exit 1
  fi
done

[ "$shell" ] && set -- "$@" -s "$shell"

cmd="$(dirname $0)/hello_world_error"
use_locallib

check "(1) Run hello_world_error silently" -i "echo \"q
\"" "$@" "$cmd -s -a \"shellia user\"" \
"--- output with ERROR from <hello_world_error.tmp.locallib> running <say_hello \"shellia user\"> ---
e:end of function say_hello
e:exit=5
s:hello shellia user
Exit because of ERROR and no interactive question allowed.
Command exited with non-zero status 2"

cmd="$(dirname $0)/hello_world_error.tmp.ia-c"
cat $(dirname $0)/hello_world_error | sed -e "s/^ia\>.*/ia -c/" > $cmd
use_locallib
check "(2) Run hello_world_error with ia -c and ignore errors" -i "echo \"i
\"" "$@" "$cmd -a \"shellia user\"" \
"--- output with ERROR from <hello_world_error.tmp.ia-c.tmp.locallib> running <say_hello \"shellia user\"> ---
e:hello shellia user
e:end of function say_hello
e:exit=5
--- (q)uit (r)edo (i)gnore (s)witch interactive ---
? "

cmd="$(dirname $0)/hello_world_error.tmp.ia-c-check"
cat $(dirname $0)/hello_world_error.tmp.ia-c | sed -e "/^ia_add\>/i ia_stdout \"^hello \"\nia_ignore \"end of function say_hello$\"\nia_ignore \"^exit=5$\"" > $cmd
use_locallib
check "(3) Run hello_world_error with ia -c and checks without options" "$@" "$cmd \"shellia user\"" "hello shellia user
Command exited with non-zero status 5"

cmd="$(dirname $0)/hello_world_error.tmp.ia-C"
cat $(dirname $0)/hello_world_error | sed -e "s/^ia\>.*/ia -C/" > $cmd
use_locallib
check "(4) Run hello_world_error with ia -C and ignore errors" -i "echo \"i
\"" "$@" "$cmd -a -- \"shellia user\"" \
"--- output with ERROR from <hello_world_error.tmp.ia-C.tmp.locallib> running <say_hello \"shellia user\"> ---
e:end of function say_hello
e:exit=5
s:hello shellia user
--- (q)uit (r)edo (i)gnore (s)witch interactive ---
? 
hello shellia user"

cmd="$(dirname $0)/hello_world_error.tmp.ia-C-check"
cat $(dirname $0)/hello_world_error.tmp.ia-C | sed -e "/^ia_add\>/i ia_ignore \"end of function say_hello$\"\nia_ignore \"^exit=5$\"" > $cmd
use_locallib
check "(5) Run hello_world_error with ia -C and checks without options" "$@" "$cmd \"shellia user\"" "hello shellia user
Command exited with non-zero status 5"