Debian Codegraph @

testsuite/bin/install_test_python

raw
1 #!/usr/bin/env python
2 #
3 # INSTALL_TEST_PYTHON, python 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 from __future__ import print_function
22 import os, sys
23
24 if len(sys.argv) != 3:
25 # print usage message
26 print('Usage:', sys.argv[0], 'initfile command[:command]', file=sys.stderr)
27 sys.exit(1)
28
29 initfile = sys.argv[1]
30 cmdlist = sys.argv[2]
31
32 if not os.access(initfile, os.R_OK):
33 print('Cannot read', initfile, file=sys.stderr)
34 sys.exit(1)
35
36 # source module init file
37 exec(open(initfile).read())
38
39 # execute command list
40 code = 0
41 runml = 0
42 for cmd in cmdlist.split(':'):
43 # call ml procedure instead of module
44 if cmd == 'ml':
45 runml = 1
46 ret = 1
47 # if command equals to NOARG string, means call with no arg passed
48 elif cmd == 'NOARG':
49 if runml == 0:
50 ret = module()
51 else:
52 ret = ml()
53 else:
54 if runml == 0:
55 ret = module(*cmd.split(','))
56 else:
57 ret = ml(*cmd.split(','))
58 if ret == 0:
59 code = 1
60 elif ret != 1:
61 print(ret)
62
63 sys.exit(code)
64
65 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: