annotate test-svn.py @ 42:44609b41868b

Added .hgignore for pyc files
author Oleg Oshmyan <chortos@inbox.lv>
date Sun, 05 Dec 2010 15:29:17 +0100
parents f90bd2d1a12b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
1 #! /usr/bin/python
3
cd4304ff1d1b Minor changes
Oleg Oshmyan <chortos@inbox.lv>
parents: 2
diff changeset
2 # Copyright (c) 2009-2010 Chortos-2 <chortos@inbox.lv>
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
3
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
4 import os, sys, shutil, time, subprocess, filecmp, optparse, signal, tempfile, tarfile, zipfile
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
5
33
f90bd2d1a12b Converted revision reporting from SVN to hg.
Oleg Oshmyan <chortos@inbox.lv>
parents: 20
diff changeset
6 version = '1.21.0 ($$REV$$)'
10
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
7 parser = optparse.OptionParser(version='test.py '+version, usage='usage: %prog [options] [problem names] [[path' + os.path.sep + 'to' + os.path.sep + ']solution-app] [test case numbers]\n\nTest case numbers can be specified in plain text or as a Python expression\nif there is only one positional argument.\n\nOnly problem names listed in testconf.py are recognized.')
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
8 parser.add_option('-u', '--update', dest='update', action='store_true', default=False, help='check for an updated version of test.py')
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
9 parser.add_option('-e', '--exclude', dest='exclude', action='append', help='test case number(s) to exclude, as a Python expression; multiple -e options can be supplied')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
10 parser.add_option('-c', '--cleanup', dest='clean', action='store_true', default=False, help='delete the copies of input/output files and exit')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
11 parser.add_option('-s', '--save-io', dest='erase', action='store_false', default=True, help='do not delete the copies of input/output files after the last test case; create copies of input files and store output in files even if the solution uses standard I/O; delete the stored input/output files if the solution uses standard I/O and the -c/--cleanup option is specified')
4
06eef313aeaa -c command line option fixes
Oleg Oshmyan <chortos@inbox.lv>
parents: 3
diff changeset
12 parser.add_option('-m', '--copy-io', dest='copyonly', action='store_true', default=False, help='only create a copy of the input/output files of the last test case for manual testing; to delete them, use options -cs or -cm')
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
13 parser.add_option('-x', '--auto-exit', dest='pause', action='store_false', default=True, help='do not wait for a key to be pressed when finished testing')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
14 parser.add_option('-p', '--python', action='store_true', default=False, help='always parse all positional arguments as a single Python expression (including the first argument even if it names an executable file)')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
15 parser.add_option('-t', '--detect-time', dest='autotime', action='store_true', default=False, help='spend a second detecting the most precise time measurement function')
15
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
16 parser.add_option('-b', dest='builtin', action='store_true', default=False)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
17
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
18 options, args = parser.parse_args()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
19 parser.destroy()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
20 del parser
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
21
15
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
22 if options.builtin:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
23 try:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
24 if args[0] == 'run':
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
25 import resource
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
26 maxmemory = int(args[1])
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
27 resource.setrlimit(resource.RLIMIT_AS, (maxmemory*1024**2, maxmemory*1024**2))
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
28 os.execv(args[2], args[2:])
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
29 else:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
30 sys.exit(2)
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
31 except:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
32 sys.exit(2)
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
33
10
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
34 def update():
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
35 import urllib
14
28b1f4853968 Get the latest published version from /test.py/version.txt
Oleg Oshmyan <chortos@inbox.lv>
parents: 12
diff changeset
36 latesttext = urllib.urlopen('http://chortos.selfip.net/~astiob/test.py/version.txt').read()
28b1f4853968 Get the latest published version from /test.py/version.txt
Oleg Oshmyan <chortos@inbox.lv>
parents: 12
diff changeset
37 latest = latesttext.split('.')
10
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
38 installed = version.split('.')
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
39 update = ''
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
40 if latest[0] > installed[0]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
41 update = 'major'
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
42 elif latest[0] == installed[0]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
43 if latest[1] > installed[1]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
44 update = 'feature'
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
45 elif latest[1] == installed[1]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
46 if latest[2] > installed[2]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
47 update = 'bug-fixing'
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
48 elif latest[2] == installed[2]:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
49 print 'You are using the latest publicly available version of test.py.'
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
50 return
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
51 if update == '':
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
52 print 'Your copy of test.py is newer than the publicly available version.'
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
53 return
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
54 print 'A ' + update + ' update to test.py is available. Downloading...'
15
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
55 sys.stdout.flush()
10
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
56 urllib.urlretrieve('http://chortos.selfip.net/~astiob/test.py/test.py', 'test.py')
14
28b1f4853968 Get the latest published version from /test.py/version.txt
Oleg Oshmyan <chortos@inbox.lv>
parents: 12
diff changeset
57 print 'Downloaded and installed. Now you are using test.py ' + latesttext + '.'
10
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
58
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
59 if options.update:
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
60 update()
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
61 sys.exit()
c87ec78f1fae Auto-update and revision number reporting added
Oleg Oshmyan <chortos@inbox.lv>
parents: 9
diff changeset
62
15
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
63 try:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
64 import resource
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
65 memlimit = True
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
66 def call(name):
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
67 pid = os.fork()
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
68 if not pid:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
69 resource.setrlimit(resource.RLIMIT_AS, (maxmemory*1024**2, maxmemory*1024**2))
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
70 os.execl(name)
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
71 else:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
72 return pid
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
73 except ImportError:
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
74 memlimit = False
c0e925ae721e Flush stdout during update; initial work on memory usage control
Oleg Oshmyan <chortos@inbox.lv>
parents: 14
diff changeset
75
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
76 globals1 = set(globals())
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
77
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
78 # Initialize some configuration variables with default values
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
79 tasknames = (os.path.curdir,)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
80 maxtime = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
81 tests = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
82 dummies = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
83 testsexcluded = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
84 padwithzeroestolength = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
85 taskweight = 100
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
86 pointmap = {}
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
87 stdio = False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
88 dummyinname = ''
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
89 dummyoutname = ''
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
90 tester = ''
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
91 maxexitcode = 0
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
92
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
93 def exectestconf_helper(name):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
94 if os.path.isfile('tests.tar'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
95 f = tarfile.open('tests.tar')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
96 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
97 exec f.extractfile(name).read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
98 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
99 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
100 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
101 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
102 if os.path.isfile('tests.zip'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
103 f = zipfile.ZipFile('tests.zip')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
104 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
105 exec f.open(name, 'rU').read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
106 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
107 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
108 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
109 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
110 if os.path.isfile('tests.tgz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
111 f = tarfile.open('tests.tgz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
112 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
113 exec f.extractfile(name).read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
114 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
115 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
116 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
117 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
118 if os.path.isfile('tests.tar.gz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
119 f = tarfile.open('tests.tar.gz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
120 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
121 exec f.extractfile(name).read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
122 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
123 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
124 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
125 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
126 if os.path.isfile('tests.tbz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
127 f = tarfile.open('tests.tbz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
128 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
129 exec f.extractfile(name).read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
130 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
131 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
132 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
133 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
134 if os.path.isfile('tests.tar.bz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
135 f = tarfile.open('tests.tar.bz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
136 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
137 exec f.extractfile(name).read() in globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
138 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
139 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
140 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
141 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
142 return False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
143
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
144 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
145 execfile('testconf.py')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
146 except IOError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
147 exc_info = sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
148 try:
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
149 execfile(os.path.join('tests', 'testconf.py'))
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
150 except IOError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
151 if not exectestconf_helper('testconf.py'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
152 raise IOError, (error.errno, 'The configuration file is missing', error.filename), exc_info
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
153 del exc_info
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
154
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
155 globals2 = set(globals())
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
156 globals2.remove('globals1')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
157 globals2 -= globals1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
158 del globals1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
159
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
160 shared = {}
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
161 g = globals()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
162 for k in globals2:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
163 shared[k] = g[k]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
164
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
165 newtasknames = []
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
166 while len(args) and args[0] in tasknames:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
167 newtasknames.append(args[0])
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
168 del args[0]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
169 if len(newtasknames):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
170 tasknames = newtasknames
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
171
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
172 scoresumoveralltasks = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
173 scoremaxoveralltasks = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
174 ntasks = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
175 nfulltasks = 0
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
176 cwd = '' # At any time this is either '' or taskname
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
177
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
178 if options.autotime:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
179 c = time.clock()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
180 time.sleep(1)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
181 c = time.clock() - c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
182 if int(c + .99999) == 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
183 clock = time.clock
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
184 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
185 clock = time.time
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
186 elif os.name == 'nt':
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
187 clock = time.clock
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
188 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
189 clock = time.time
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
190
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
191 if options.copyonly:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
192 options.erase = False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
193
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
194 def existstestcase_helper(name):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
195 if os.path.isfile('tests.tar'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
196 f = tarfile.open('tests.tar')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
197 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
198 f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
199 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
200 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
201 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
202 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
203 if os.path.isfile('tests.zip'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
204 f = zipfile.ZipFile('tests.zip')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
205 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
206 f.getinfo(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
207 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
208 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
209 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
210 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
211 if os.path.isfile('tests.tgz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
212 f = tarfile.open('tests.tgz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
213 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
214 f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
215 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
216 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
217 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
218 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
219 if os.path.isfile('tests.tar.gz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
220 f = tarfile.open('tests.tar.gz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
221 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
222 f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
223 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
224 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
225 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
226 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
227 if os.path.isfile('tests.tbz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
228 f = tarfile.open('tests.tbz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
229 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
230 f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
231 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
232 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
233 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
234 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
235 if os.path.isfile('tests.tar.bz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
236 f = tarfile.open('tests.tar.bz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
237 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
238 f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
239 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
240 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
241 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
242 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
243 return False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
244
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
245 def existstestcase(name):
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
246 if os.path.isfile(os.path.join('tests', taskname, name)) or os.path.isfile(os.path.join('tests', name)):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
247 return True
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
248 if cwd and (os.path.isfile(os.path.join(oldcwd, 'tests', cwd, name)) or os.path.isfile(os.path.join(oldcwd, 'tests', name))):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
249 return True
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
250 if existstestcase_helper(os.path.join(taskname, name)) or existstestcase_helper(name):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
251 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
252 if cwd:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
253 os.chdir(oldcwd)
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
254 if existstestcase_helper(os.path.join(cwd, name)) or existstestcase_helper(name):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
255 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
256 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
257 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
258 return False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
259
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
260 def opentestcase_helper(name):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
261 if os.path.isfile('tests.tar'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
262 f = tarfile.open('tests.tar')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
263 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
264 c = f.extractfile(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
265 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
266 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
267 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
268 if os.path.isfile('tests.zip'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
269 f = zipfile.ZipFile('tests.zip')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
270 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
271 c = f.open(name, 'rU')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
272 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
273 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
274 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
275 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
276 if os.path.isfile('tests.tgz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
277 f = tarfile.open('tests.tgz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
278 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
279 c = f.extractfile(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
280 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
281 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
282 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
283 if os.path.isfile('tests.tar.gz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
284 f = tarfile.open('tests.tar.gz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
285 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
286 c = f.extractfile(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
287 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
288 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
289 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
290 if os.path.isfile('tests.tbz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
291 f = tarfile.open('tests.tbz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
292 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
293 c = f.extractfile(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
294 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
295 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
296 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
297 if os.path.isfile('tests.tar.bz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
298 f = tarfile.open('tests.tar.bz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
299 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
300 c = f.extractfile(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
301 return c
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
302 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
303 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
304 return None
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
305
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
306 def opentestcase(name):
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
307 if os.path.isfile(os.path.join('tests', taskname, name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
308 return open(os.path.join('tests', taskname, name), 'rU')
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
309 elif os.path.isfile(os.path.join('tests', name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
310 return open(os.path.join('tests', name), 'rU')
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
311 f = opentestcase_helper(os.path.join(taskname, name))
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
312 if not f:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
313 f = opentestcase_helper(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
314 if f:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
315 return f
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
316 if cwd:
3
cd4304ff1d1b Minor changes
Oleg Oshmyan <chortos@inbox.lv>
parents: 2
diff changeset
317 if os.path.isfile(os.path.join(oldcwd, 'tests', cwd, name)):
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
318 return open(os.path.join(oldcwd, 'tests', cwd, name), 'rU')
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
319 elif os.path.isfile(os.path.join(oldcwd, 'tests', name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
320 return open(os.path.join(oldcwd, 'tests', name), 'rU')
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
321 os.chdir(oldcwd)
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
322 f = opentestcase_helper(os.path.join(cwd, name))
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
323 if not f:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
324 f = opentestcase_helper(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
325 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
326 if f:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
327 return f
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
328 raise KeyError, 'The test-case-defining file \'' + name + '\' cannot be found'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
329
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
330 def copytestcase_helper(name, target):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
331 if os.path.isfile('tests.tar'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
332 f = tarfile.open('tests.tar')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
333 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
334 m = f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
335 m.name = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
336 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
337 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
338 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
339 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
340 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
341 if os.path.isfile('tests.zip'):
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
342 if not os.path.isabs(target):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
343 f = zipfile.ZipFile('tests.zip')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
344 try:
19
d4fc9341664e Fixed an exception when tests.zip contained test cases in its root
Oleg Oshmyan <chortos@inbox.lv>
parents: 15
diff changeset
345 m = f.getinfo(name)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
346 m.filename = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
347 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
348 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
349 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
350 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
351 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
352 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
353 oldcwd = os.getcwdu()
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
354 os.chdir('/') # FIXME: portability?
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
355 f = zipfile.ZipFile(os.path.join(oldcwd, 'tests.zip'))
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
356 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
357 m = f.getinfo(name)
20
5bfa23cd638d More ZIP archive fixes
Oleg Oshmyan <chortos@inbox.lv>
parents: 19
diff changeset
358 m.filename = os.path.relpath(target)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
359 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
360 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
361 os.chdir(oldcwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
362 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
363 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
364 f.close()
20
5bfa23cd638d More ZIP archive fixes
Oleg Oshmyan <chortos@inbox.lv>
parents: 19
diff changeset
365 os.chdir(oldcwd)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
366 if os.path.isfile('tests.tgz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
367 f = tarfile.open('tests.tgz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
368 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
369 m = f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
370 m.name = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
371 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
372 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
373 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
374 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
375 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
376 if os.path.isfile('tests.tar.gz'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
377 f = tarfile.open('tests.tar.gz')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
378 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
379 m = f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
380 m.name = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
381 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
382 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
383 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
384 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
385 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
386 if os.path.isfile('tests.tbz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
387 f = tarfile.open('tests.tbz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
388 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
389 m = f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
390 m.name = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
391 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
392 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
393 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
394 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
395 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
396 if os.path.isfile('tests.tar.bz2'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
397 f = tarfile.open('tests.tar.bz2')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
398 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
399 m = f.getmember(name)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
400 m.name = target
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
401 f.extract(m)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
402 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
403 return True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
404 except KeyError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
405 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
406 return False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
407
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
408 def copytestcase(name, target):
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
409 if os.path.isfile(os.path.join('tests', taskname, name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
410 shutil.copyfile(os.path.join('tests', taskname, name), target)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
411 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
412 elif os.path.isfile(os.path.join('tests', name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
413 shutil.copyfile(os.path.join('tests', name), target)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
414 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
415 if copytestcase_helper(os.path.join(taskname, name), target) or copytestcase_helper(name, target):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
416 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
417 if cwd:
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
418 if os.path.isfile(os.path.join(oldcwd, 'tests', cwd, name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
419 shutil.copyfile(os.path.join(oldcwd, 'tests', cwd, name), target)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
420 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
421 elif os.path.isfile(os.path.join(oldcwd, 'tests', name)):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
422 shutil.copyfile(os.path.join(oldcwd, 'tests', name), target)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
423 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
424 os.chdir(oldcwd)
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
425 if copytestcase_helper(os.path.join(cwd, name), target) or copytestcase_helper(name, target):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
426 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
427 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
428 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
429 raise KeyError, 'The test-case-defining file \'' + name + '\' cannot be found'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
430
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
431 # Always chdir if the directory exists but use any existing config
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
432 def chdir_and_exec_testconf():
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
433 global cwd
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
434 cwd = ''
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
435 if os.path.isdir(taskname):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
436 os.chdir(taskname)
3
cd4304ff1d1b Minor changes
Oleg Oshmyan <chortos@inbox.lv>
parents: 2
diff changeset
437 if taskname != os.path.curdir:
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
438 cwd = taskname
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
439 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
440 execfile('testconf.py', globals())
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
441 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
442 except IOError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
443 pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
444 if not cwd:
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
445 if os.path.isfile(os.path.join('tests', taskname, 'testconf.py')):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
446 execfile(os.path.join('tests', taskname, 'testconf.py'), globals())
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
447 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
448 if os.path.isfile(os.path.join('tests', 'testconf.py')):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
449 execfile(os.path.join('tests', 'testconf.py'), globals())
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
450 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
451 if exectestconf_helper(os.path.join(taskname, 'testconf.py')) or exectestconf_helper('testconf.py'):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
452 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
453 if cwd:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
454 os.chdir(oldcwd)
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
455 if os.path.isfile(os.path.join('tests', cwd, 'testconf.py')):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
456 execfile(os.path.join('tests', cwd, 'testconf.py'), globals())
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
457 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
458 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
459 if os.path.isfile(os.path.join('tests', 'testconf.py')):
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
460 execfile(os.path.join('tests', 'testconf.py'), globals())
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
461 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
462 return
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
463 if exectestconf_helper(os.path.join(cwd, 'testconf.py')) or exectestconf_helper('testconf.py'):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
464 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
465 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
466 if os.path.isfile('testconf.py'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
467 execfile('testconf.py', globals())
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
468 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
469 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
470 os.chdir(cwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
471 elif os.path.isfile('testconf.py'):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
472 execfile('testconf.py', globals())
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
473 return
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
474 raise KeyError, 'The configuration file for task ' + taskname + ' is missing'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
475
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
476 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
477 name
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
478 namedefined = True
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
479 except Exception:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
480 namedefined = False
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
481
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
482 for taskname in tasknames:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
483 if ntasks:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
484 print
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
485
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
486 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
487 if len(tasknames) > 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
488 print taskname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
489 except Exception:
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
490 if taskname != os.path.curdir or ntasks:
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
491 print taskname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
492
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
493 try: del inname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
494 except NameError: pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
495 try: del outname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
496 except NameError: pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
497 try: del ansname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
498 except NameError: pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
499
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
500 if not namedefined and taskname != os.path.curdir:
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
501 name = os.path.join(os.path.curdir, taskname)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
502 for k in shared:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
503 g[k] = shared[k]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
504
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
505 oldcwd = os.getcwdu()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
506 chdir_and_exec_testconf()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
507
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
508 if options.clean:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
509 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
510 if not stdio or tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
511 if not tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
512 inname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
513 outname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
514 if tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
515 ansname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
516 except NameError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
517 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ', 1), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
518 if not options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
519 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
520 inname = inname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
521 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
522 inname = taskname + '.in'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
523 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
524 outname = outname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
525 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
526 outname = taskname + '.out'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
527 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
528 ansname = ansname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
529 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
530 ansname = taskname + '.ans'
4
06eef313aeaa -c command line option fixes
Oleg Oshmyan <chortos@inbox.lv>
parents: 3
diff changeset
531 elif not stdio or tester or not options.erase:
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
532 inname = inname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
533 outname = outname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
534 if tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
535 ansname = ansname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
536 if not stdio or tester or not options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
537 if os.path.exists(inname): os.remove(inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
538 if os.path.exists(outname): os.remove(outname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
539 if (tester or not options.erase) and ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
540 if os.path.exists(ansname): os.remove(ansname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
541 continue
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
542
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
543 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
544 name
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
545 except NameError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
546 if str(error).count('name') == 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
547 raise NameError, 'configuration ' + str(error), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
548 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
549 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ', 1), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
550
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
551 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
552 if not stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
553 inname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
554 outname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
555 testcaseinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
556 if tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
557 outname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
558 if ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
559 testcaseoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
560 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
561 testcaseoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
562 except NameError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
563 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ', 1), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
564
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
565 if not options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
566 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
567 inname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
568 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
569 inname = taskname + '.in'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
570 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
571 outname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
572 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
573 outname = taskname + '.out'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
574 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
575 ansname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
576 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
577 ansname = taskname + '.ans'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
578
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
579 if options.pause:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
580 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
581 pause
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
582 except NameError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
583 if os.name == 'posix':
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
584 pause = 'read -s -n 1'
3
cd4304ff1d1b Minor changes
Oleg Oshmyan <chortos@inbox.lv>
parents: 2
diff changeset
585 print 'Configuration ' + str(error).replace('name ', 'variable ') + '; it was devised automatically but the choice might be incorrect, so test.py might exit immediately after the testing is completed.'
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
586 elif os.name == 'nt':
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
587 pause = 'pause'
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
588 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
589 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ') + ' and cannot be devised automatically', sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
590
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
591 if not dummyinname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
592 dummyinname = testcaseinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
593 if not dummyoutname and (not tester or ansname):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
594 dummyoutname = testcaseoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
595
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
596 dummyinname = dummyinname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
597 dummyoutname = dummyoutname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
598 testcaseinname = testcaseinname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
599 if not stdio or not options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
600 inname = inname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
601 outname = outname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
602 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
603 ansname = ansname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
604 except NameError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
605 pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
606 if tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
607 try: inname = inname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
608 except NameError: pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
609 outname = outname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
610 if ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
611 ansname = ansname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
612 testcaseoutname = testcaseoutname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
613 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
614 testcaseoutname = testcaseoutname.replace('%', taskname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
615
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
616 if isinstance(padwithzeroestolength, tuple):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
617 padwithzeroestolength, paddummieswithzeroestolength = padwithzeroestolength
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
618 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
619 paddummieswithzeroestolength = padwithzeroestolength
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
620
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
621 if options.python:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
622 dummies = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
623 s = ' '.join(args)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
624 tests = eval(s)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
625 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
626 tests.__iter__
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
627 except AttributeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
628 tests = (tests,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
629 elif len(args):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
630 if os.path.exists(args[0]):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
631 name = args[0]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
632 del args[0]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
633 if len(args) > 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
634 dummies = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
635 tests = args
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
636 elif len(args):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
637 dummies = ()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
638 s = args[0]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
639 if len(s) < padwithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
640 s = s.zfill(padwithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
641 if existstestcase(testcaseinname.replace('$', s)):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
642 tests = (s,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
643 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
644 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
645 tests = eval(args[0])
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
646 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
647 tests.__iter__
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
648 except AttributeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
649 tests = (tests,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
650 except Exception:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
651 tests = (s,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
652
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
653 if options.exclude:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
654 testsexcluded = []
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
655 for i in options.exclude:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
656 v = eval(i)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
657 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
658 testsexcluded.extend(v)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
659 except TypeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
660 testsexcluded.append(v)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
661
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
662 # Windows doesn't like paths beginning with .\ and not ending with an extension
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
663 name = os.path.normcase(name)
2
bddcc05aba59 Finished path portability improvements
Oleg Oshmyan <chortos@inbox.lv>
parents: 1
diff changeset
664 if os.name == 'nt' and name.startswith('.\\'):
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
665 name = name[2:]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
666
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
667 newpointmap = {}
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
668
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
669 for i in pointmap:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
670 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
671 for j in i:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
672 newpointmap[j] = pointmap[i]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
673 except TypeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
674 newpointmap[i] = pointmap[i]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
675
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
676 pointmap = newpointmap
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
677
9
ed90b375d197 Award maxexitcode points by default
Oleg Oshmyan <chortos@inbox.lv>
parents: 6
diff changeset
678 if not tester:
ed90b375d197 Award maxexitcode points by default
Oleg Oshmyan <chortos@inbox.lv>
parents: 6
diff changeset
679 maxexitcode = 0
ed90b375d197 Award maxexitcode points by default
Oleg Oshmyan <chortos@inbox.lv>
parents: 6
diff changeset
680
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
681 if maxtime > 0:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
682 strmaxtime = '/%.3f' % maxtime
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
683 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
684 strmaxtime = ''
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
685
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
686 padoutputtolength = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
687 ntests = []
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
688
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
689 for j in dummies:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
690 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
691 j.__iter__
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
692 except AttributeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
693 j = (j,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
694 ntests.append((j, True))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
695 for i in j:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
696 s = str(i)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
697 if len(s) < paddummieswithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
698 s = s.zfill(paddummieswithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
699 s = 'sample ' + s
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
700 if padoutputtolength < len(s):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
701 padoutputtolength = len(s)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
702
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
703 for j in tests:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
704 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
705 j.__iter__
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
706 except AttributeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
707 j = (j,)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
708 ntests.append((j, False))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
709 for i in j:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
710 s = str(i)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
711 if len(s) < padwithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
712 s = s.zfill(padwithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
713 if padoutputtolength < len(s):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
714 padoutputtolength = len(s)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
715
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
716 tests = ntests
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
717 score = maxpoints = ncorrect = ntotal = ncorrectvalued = nvalued = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
718
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
719 if options.copyonly:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
720 j, isdummy = tests[-1]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
721 if isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
722 realinname = dummyinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
723 realoutname = dummyoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
724 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
725 realinname = testcaseinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
726 realoutname = testcaseoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
727 for i in j:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
728 if i in testsexcluded and not isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
729 continue
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
730 s = str(i)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
731 if isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
732 if len(s) < paddummieswithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
733 s = s.zfill(paddummieswithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
734 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
735 if len(s) < padwithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
736 s = s.zfill(padwithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
737 copytestcase(realinname.replace('$', s), inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
738 if ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
739 copytestcase(realoutname.replace('$', s), ansname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
740 continue
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
741
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
742 for j, isdummy in tests:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
743 ncorrectgrp = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
744 ntotalgrp = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
745 scoregrp = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
746 maxpointsgrp = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
747 if isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
748 realinname = dummyinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
749 realoutname = dummyoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
750 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
751 realinname = testcaseinname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
752 realoutname = testcaseoutname
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
753 for i in j:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
754 if i in testsexcluded and not isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
755 continue
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
756 ntotalgrp += 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
757 s = str(i)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
758 if isdummy:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
759 npoints = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
760 if len(s) < paddummieswithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
761 s = s.zfill(paddummieswithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
762 spref = 'sample '
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
763 else:
9
ed90b375d197 Award maxexitcode points by default
Oleg Oshmyan <chortos@inbox.lv>
parents: 6
diff changeset
764 npoints = pointmap.get(None, maxexitcode if maxexitcode and isinstance(maxexitcode, int) else 1)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
765 npoints = pointmap.get(i, npoints)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
766 maxpointsgrp += npoints
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
767 if npoints:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
768 nvalued += 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
769 if len(s) < padwithzeroestolength:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
770 s = s.zfill(padwithzeroestolength)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
771 spref = ''
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
772 print ' ' * (padoutputtolength - len(spref + s)) + spref + s + ':',
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
773 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
774 outputdata = open(os.devnull, 'w')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
775 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
776 f = tempfile.NamedTemporaryFile(delete=False)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
777 inputdatafname = f.name
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
778 f.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
779 copytestcase(realinname.replace('$', s), inputdatafname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
780 inputdata = open(inputdatafname, 'rU')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
781 if options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
782 tempoutput = tempfile.TemporaryFile('w+')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
783 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
784 tempoutput = open(outname, 'w+')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
785 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
786 proc = subprocess.Popen(name, stdin=inputdata, stdout=tempoutput, stderr=outputdata, universal_newlines=True)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
787 except OSError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
788 raise OSError, 'The program to be tested cannot be launched: ' + str(error), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
789 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
790 if os.path.exists(outname):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
791 os.remove(outname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
792 copytestcase(realinname.replace('$', s), inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
793 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
794 proc = subprocess.Popen(name, stdin=outputdata, stdout=outputdata, stderr=outputdata, universal_newlines=True)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
795 except OSError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
796 raise OSError, 'The program to be tested cannot be launched: ' + str(error), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
797 cl = clock()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
798 if maxtime > 0:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
799 while 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
800 proc.poll()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
801 elapsed = clock() - cl
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
802 if proc.returncode == None:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
803 if elapsed >= maxtime:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
804 print '%.3f%s s, 0/%d, time limit exceeded' % (elapsed, strmaxtime, npoints)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
805 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
806 while proc.returncode == None:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
807 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
808 proc.terminate()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
809 except OSError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
810 pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
811 except AttributeError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
812 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
813 os.kill(proc.pid, signal.SIGTERM)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
814 except Exception:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
815 pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
816 proc.poll()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
817 outputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
818 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
819 tempoutput.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
820 break
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
821 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
822 print '%.3f%s s,' % (elapsed, strmaxtime),
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
823 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
824 elapsed = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
825 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
826 tempoutput.seek(0)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
827 lines = tempoutput.readlines()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
828 tempoutput.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
829 break
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
830 if elapsed >= maxtime:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
831 continue
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
832 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
833 data = proc.communicate()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
834 elapsed = clock() - cl
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
835 print '%.3f%s s,' % (elapsed, strmaxtime),
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
836 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
837 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
838 tempoutput.seek(0)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
839 lines = tempoutput.readlines()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
840 tempoutput.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
841 outputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
842 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
843 inputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
844 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
845 os.unlink(inputdatafname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
846 except Exception:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
847 pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
848 if proc.returncode > 0:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
849 print '0/%d, non-zero return code %d' % (npoints, proc.returncode)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
850 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
851 elif proc.returncode < 0:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
852 print '0/%d, terminated by signal %d' % (npoints, -proc.returncode)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
853 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
854 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
855 if not tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
856 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
857 outputdata = opentestcase(realoutname.replace('$', s))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
858 r = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
859 data = outputdata.read().splitlines(True)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
860 if len(lines) != len(data):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
861 r = 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
862 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
863 for i in zip(lines, data):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
864 if i[0] != i[1]:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
865 r = 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
866 break
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
867 outputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
868 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
869 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
870 inputdata = open(outname, 'rU')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
871 except IOError:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
872 print '0/%g, output file not created or not readable' % npoints
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
873 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
874 r = None
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
875 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
876 outputdata = opentestcase(realoutname.replace('$', s))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
877 r = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
878 lines = inputdata.readlines()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
879 data = outputdata.read().splitlines(True)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
880 if len(lines) != len(data):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
881 r = 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
882 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
883 for i in zip(lines, data):
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
884 if i[0] != i[1]:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
885 r = 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
886 break
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
887 inputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
888 outputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
889 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
890 if ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
891 copytestcase(realoutname.replace('$', s), ansname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
892 if stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
893 try: copytestcase(realinname.replace('$', s), inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
894 except NameError: pass
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
895 outputdata = open(outname, 'w')
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
896 outputdata.writelines(lines)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
897 outputdata.close()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
898 try:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
899 proc = subprocess.Popen(tester, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
900 except OSError, error:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
901 raise OSError, 'The tester application cannot be launched: ' + str(error), sys.exc_info()[2]
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
902 data = proc.communicate()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
903 r = proc.returncode
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
904 if tester and data[0]:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
905 data = ''.join((' (', data[0].strip(), ')'))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
906 else:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
907 data = ''
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
908 if not maxexitcode and r or maxexitcode and not r:
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
909 print '0/%g, wrong answer%s' % (npoints, data)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
910 sys.stdout.flush()
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
911 elif not maxexitcode and r == 0 or maxexitcode and r >= maxexitcode:
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
912 print '%g/%g, OK%s' % (npoints, npoints, data)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
913 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
914 scoregrp += npoints
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
915 ncorrectgrp += 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
916 if npoints:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
917 ncorrectvalued += 1
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
918 elif maxexitcode and r != None:
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
919 actualpoints = npoints*r/maxexitcode if not npoints*r%maxexitcode else float(npoints*r)/maxexitcode
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
920 print '%g/%g, partly OK%s' % (actualpoints, npoints, data)
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
921 sys.stdout.flush()
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
922 scoregrp += actualpoints
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
923 ncorrectgrp += 1
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
924 if npoints:
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
925 ncorrectvalued += 1
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
926 if ntotalgrp:
6
b0034b18f942 maxexitcode now gets on with test groups
Oleg Oshmyan <chortos@inbox.lv>
parents: 5
diff changeset
927 if ncorrectgrp < ntotalgrp:
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
928 scoregrp = 0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
929 if ntotalgrp > 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
930 print 'Group total: %d/%d tests; %g/%g points' % (ncorrectgrp, ntotalgrp, scoregrp, maxpointsgrp)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
931 sys.stdout.flush()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
932 ncorrect += ncorrectgrp
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
933 ntotal += ntotalgrp
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
934 score += scoregrp
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
935 maxpoints += maxpointsgrp
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
936
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
937 if options.erase:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
938 if not stdio or tester:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
939 if os.path.exists(inname): os.remove(inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
940 if os.path.exists(outname): os.remove(outname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
941 if tester and ansname:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
942 if os.path.exists(ansname): os.remove(ansname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
943 elif stdio:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
944 copytestcase(realinname.replace('$', s), inname)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
945 copytestcase(realoutname.replace('$', s), ansname)
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
946 actualpoints = (score*taskweight/maxpoints if not score*taskweight%maxpoints else float(score*taskweight)/maxpoints) if maxpoints else 0
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
947 if nvalued != ntotal:
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
948 print 'Grand total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, score, maxpoints, actualpoints, taskweight)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
949 else:
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
950 print 'Grand total: %d/%d tests; %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, score, maxpoints, actualpoints, taskweight)
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
951
5
eb15a5a9b026 Output validators can now award partial scores
Oleg Oshmyan <chortos@inbox.lv>
parents: 4
diff changeset
952 scoresumoveralltasks += actualpoints
0
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
953 scoremaxoveralltasks += taskweight
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
954 ntasks += 1
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
955 nfulltasks += int((score == maxpoints) if maxpoints else (taskweight == 0))
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
956
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
957 os.chdir(oldcwd)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
958
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
959 if options.clean or options.copyonly:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
960 sys.exit()
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
961
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
962 if ntasks != 1:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
963 print
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
964 print 'Grand grand total: %g/%g weighted points; %d/%d problems solved fully' % (scoresumoveralltasks, scoremaxoveralltasks, nfulltasks, ntasks)
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
965
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
966 if options.pause:
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
967 print 'Press any key to exit... ',
b9622c1e2197 Created the repository
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
968 sys.stdout.flush()
19
d4fc9341664e Fixed an exception when tests.zip contained test cases in its root
Oleg Oshmyan <chortos@inbox.lv>
parents: 15
diff changeset
969 os.system(pause + ' >' + os.devnull)