File: test.wrong-missing-ia_init

package info (click to toggle)
shellia 5.10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 792 kB
  • sloc: sh: 7,840; makefile: 34
file content (108 lines) | stat: -rwxr-xr-x 3,517 bytes parent folder | download | duplicates (4)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# vim: set filetype=sh :
#        file: test.wrong-missing-ia_init
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
#     license: GNU General Public License, version 3
# description: test if some shellia programming errors are found
#              automatically
#    see also: example.wrong-missing-ia_init

# The following tests are included:

. ./tstlib

# setup_err <err>
setup_err()
{
  if [ "$(grep "# $1 if line is missing" $name)" ]; then
    sed "s/^\(\s*\)\(.* # $1 .*\)/\1#\2/" $name > $name.tmp.$1
  elif [ "$(grep "# $1 if line exists" $name)" ]; then
    sed "s/^\(\s*\)#\(.* # $1 .*\)/\1\2/" $name > $name.tmp.$1
  else
    echo "test.wrong-missing-ia_init: internal error" >&2
    exit 1
  fi
  chmod 755 $name.tmp.$1
  cmd="$(dirname $0)/$name.tmp.$1"
}

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

name=example.wrong-missing-ia_init
cmd="$(dirname $0)/$name"

ia_logfile="$(mktemp)"
export ia_logfile

rm -f $ia_logfile
check "(1) without error" "$@" "$cmd -a" \
"main p7ogram start
function fun1 start
function fun2 start
function fun2 end
function fun1 end
main program end"

check "(2) check logfile" "$@" "cat $ia_logfile" \
"|example.wrong-missing-ia_init
||example.wrong-missing-ia_init/fun1
|||example.wrong-missing-ia_init/fun1/fun2"

rm -f $ia_logfile

setup_err err1
check "(3) with error err1" "$@" "$cmd -a" \
"main p7ogram start
function fun1 start
shellia: script error: example.wrong-missing-ia_init.tmp.err1/fun1/fun2: <ia_add> is called without previous calling <eval \"\$ia_init\">
Command exited with non-zero status 1"

check "(4) check logfile" "$@" "cat $ia_logfile" \
"|example.wrong-missing-ia_init.tmp.err1
||example.wrong-missing-ia_init.tmp.err1/fun1
||shellia: script error: example.wrong-missing-ia_init.tmp.err1/fun1/fun2: <ia_add> is called without previous calling <eval \"\$ia_init\">"

setup_err err2
check "(5) with error err2" "$@" "$cmd -a" \
"main p7ogram start
function fun1 start
shellia: script error: example.wrong-missing-ia_init.tmp.err2/fun1/fun2: <eval \"\$ia_init\"> is called again, before calling <ia>
Command exited with non-zero status 1"

setup_err err3
check "(6) with error err3" "$@" "$cmd -a" \
"main p7ogram start
shellia: script error: example.wrong-missing-ia_init.tmp.err3/fun1: <ia_add> is called without previous calling <eval \"\$ia_init\">
Command exited with non-zero status 1"

setup_err err4
check "(7) with error err4" "$@" "$cmd -a" \
"main p7ogram start
shellia: script error: example.wrong-missing-ia_init.tmp.err4/fun1: <eval \"\$ia_init\"> is called again, before calling <ia>
Command exited with non-zero status 1"

setup_err err5
check "(8) with error err5" "$@" "$cmd -a" \
"shellia: script error: example.wrong-missing-ia_init.tmp.err5/<outside-of-function>: <ia> is called without previous calling <eval \"\$ia_init\">
Command exited with non-zero status 1"

setup_err err6
check "(9) with error err6" "$@" "$cmd -a" \
"shellia: script error: example.wrong-missing-ia_init.tmp.err6/<outside-of-function>: <ia_add> is called without previous calling <eval \"\$ia_init\">
Command exited with non-zero status 1"

setup_err err7
check "(10) with error err7" "$@" "$cmd -a" \
"shellia: script error: example.wrong-missing-ia_init.tmp.err7/<outside-of-function>: <eval \"\$ia_init\"> is called again, before calling <ia>
Command exited with non-zero status 1"

rm -f $ia_logfile