Debian Codegraph @

testsuite/bin/install_test_ruby

raw
1 #!/usr/bin/env ruby
2 #
3 # INSTALL_TEST_RUBY, ruby 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 ARGV.length != 2 then
22 # print usage message
23 STDERR.puts("Usage: #{$0} initfile command[:command]")
24 exit(1)
25 end
26
27 initfile = ARGV[0]
28 cmdlist = ARGV[1].split(':')
29 # empty command list, means one empty command
30 if cmdlist.length == 0 then
31 cmdlist.push('')
32 end
33
34 if not File.readable?(initfile) then
35 STDERR.puts("Cannot read #{initfile}")
36 exit(1)
37 end
38
39 # source module init file
40 require initfile
41
42 # execute command list
43 code = 0
44 runml = 0
45 cmdlist.each do |cmd|
46 # call ml procedure instead of module
47 if cmd == 'ml' then
48 runml = 1
49 ret = true
50 # if command equals to NOARG string, means call with no arg passed
51 elsif cmd == 'NOARG' then
52 if runml == 0 then
53 ret = ENVModule.module()
54 else
55 ret = ENVModule.ml()
56 end
57 elsif
58 arglist = cmd.split(/,/, -1)
59 # empty arg list, means one empty arg
60 if arglist.length == 0 then
61 arglist.push('')
62 end
63 if runml == 0 then
64 ret = ENVModule.module(arglist)
65 else
66 ret = ENVModule.ml(arglist)
67 end
68 end
69 if ret == false then
70 code = 1
71 elsif ret != true then
72 puts(ret)
73 end
74 end
75
76 exit(code)
77
78 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: