annotate test-svn.py @ 11:231e3317477d

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