comparison test.py @ 3:cd4304ff1d1b

Minor changes
author Oleg Oshmyan <chortos@inbox.lv>
date Fri, 22 Jan 2010 20:16:07 +0000
parents bddcc05aba59
children 06eef313aeaa
comparison
equal deleted inserted replaced
2:bddcc05aba59 3:cd4304ff1d1b
1 #! /usr/bin/python 1 #! /usr/bin/python
2 # Copyright (c) 2009 Chortos-2 <chortos@inbox.lv> 2 # Copyright (c) 2009-2010 Chortos-2 <chortos@inbox.lv>
3 3
4 import os, sys, shutil, time, subprocess, filecmp, optparse, signal, tempfile, tarfile, zipfile 4 import os, sys, shutil, time, subprocess, filecmp, optparse, signal, tempfile, tarfile, zipfile
5 5
6 parser = optparse.OptionParser(version='test.py 1.21.0 (SVN)', 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.') 6 parser = optparse.OptionParser(version='test.py 1.21.0 (SVN)', 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.')
7 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') 7 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')
254 if not f: 254 if not f:
255 f = opentestcase_helper(name) 255 f = opentestcase_helper(name)
256 if f: 256 if f:
257 return f 257 return f
258 if cwd: 258 if cwd:
259 if os.path.isfile(os.path.join(oldcwd, 'tests', cwd, name): 259 if os.path.isfile(os.path.join(oldcwd, 'tests', cwd, name)):
260 return open(os.path.join(oldcwd, 'tests', cwd, name), 'rU') 260 return open(os.path.join(oldcwd, 'tests', cwd, name), 'rU')
261 elif os.path.isfile(os.path.join(oldcwd, 'tests', name)): 261 elif os.path.isfile(os.path.join(oldcwd, 'tests', name)):
262 return open(os.path.join(oldcwd, 'tests', name), 'rU') 262 return open(os.path.join(oldcwd, 'tests', name), 'rU')
263 os.chdir(oldcwd) 263 os.chdir(oldcwd)
264 f = opentestcase_helper(os.path.join(cwd, name)) 264 f = opentestcase_helper(os.path.join(cwd, name))
374 def chdir_and_exec_testconf(): 374 def chdir_and_exec_testconf():
375 global cwd 375 global cwd
376 cwd = '' 376 cwd = ''
377 if os.path.isdir(taskname): 377 if os.path.isdir(taskname):
378 os.chdir(taskname) 378 os.chdir(taskname)
379 if taskname != : 379 if taskname != os.path.curdir:
380 cwd = taskname 380 cwd = taskname
381 try: 381 try:
382 execfile('testconf.py', globals()) 382 execfile('testconf.py', globals())
383 return 383 return
384 except IOError: 384 except IOError:
522 try: 522 try:
523 pause 523 pause
524 except NameError, error: 524 except NameError, error:
525 if os.name == 'posix': 525 if os.name == 'posix':
526 pause = 'read -s -n 1' 526 pause = 'read -s -n 1'
527 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 complete.' 527 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.'
528 elif os.name == 'nt': 528 elif os.name == 'nt':
529 pause = 'pause' 529 pause = 'pause'
530 else: 530 else:
531 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ') + ' and cannot be devised automatically', sys.exc_info()[2] 531 raise NameError, 'configuration ' + str(error).replace('name ', 'variable ') + ' and cannot be devised automatically', sys.exc_info()[2]
532 532