Debian Codegraph @

testsuite/bin/install_test_tcl

raw
1 #!/usr/bin/env tclsh
2 #
3 # INSTALL_TEST_TCL, tcl test script for install non-reg suite
4 # Copyright (C) 2017-2021 Xavier Delaruelle
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ##########################################################################
20
21 if {$argc != 2} {
22 # print usage message
23 puts stderr "Usage: $argv0 initfile command\[:command\]"
24 exit 1
25 }
26
27 set moduleproc module
28 set initfile [lindex $argv 0]
29 set cmdlist [split [lindex $argv 1] ":"]
30 # empty command list, means one empty command
31 if {![llength $cmdlist]} {
32 lappend cmdlist {}
33 # call ml procedure instead of module
34 } elseif {[lindex $cmdlist 0] eq {ml}} {
35 set moduleproc ml
36 set cmdlist [lrange $cmdlist 1 end]
37 }
38
39 if {![file readable $initfile]} {
40 puts stderr "Cannot read $initfile"
41 exit 1
42 }
43
44 # source module init file
45 source $initfile
46
47 # execute command list
48 set code 0
49 foreach cmd $cmdlist {
50 # if command equals to NOARG string, means call with no arg passed
51 if {$cmd eq "NOARG"} {
52 set arglist ""
53 } else {
54 set arglist [split $cmd ","]
55 # empty arg list, means one empty arg
56 if {![llength $arglist]} {
57 lappend arglist {}
58 }
59 }
60 if {[catch {
61 set ret [$moduleproc {*}$arglist]
62 if {$ret == 0} {
63 set code 1
64 } elseif {![string is integer $ret]} {
65 puts stdout $ret
66 }
67 }]} {
68 set code 1
69 }
70 }
71
72 exit $code
73
74 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: