comparison testcases.py @ 57:855bdfeb32a6

NameErrors within call() are now reported
author Oleg Oshmyan <chortos@inbox.lv>
date Tue, 21 Dec 2010 02:28:57 +0200
parents 693a938bdeee
children c95addbe0851
comparison
equal deleted inserted replaced
56:693a938bdeee 57:855bdfeb32a6
99 except (ImportError, AttributeError): 99 except (ImportError, AttributeError):
100 pass 100 pass
101 else: 101 else:
102 # TODO: implement Win32 call() 102 # TODO: implement Win32 call()
103 pass 103 pass
104 call = None
104 else: 105 else:
105 # Make SIGCHLD interrupt sleep() and select() 106 # Make SIGCHLD interrupt sleep() and select()
106 def bury_child(signum, frame): 107 def bury_child(signum, frame):
107 try: 108 try:
108 bury_child.case.time_stopped = clock() 109 bury_child.case.time_stopped = clock()
443 contextmgr = Copying(case.infile, inputdatafname) 444 contextmgr = Copying(case.infile, inputdatafname)
444 with contextmgr: 445 with contextmgr:
445 # FIXME: this U doesn't do anything good for the child process, does it? 446 # FIXME: this U doesn't do anything good for the child process, does it?
446 with open(inputdatafname, 'rU') as infile: 447 with open(inputdatafname, 'rU') as infile:
447 with tempfile.TemporaryFile('w+') if options.erase and not case.validator else open(case.problem.config.outname, 'w+') as outfile: 448 with tempfile.TemporaryFile('w+') if options.erase and not case.validator else open(case.problem.config.outname, 'w+') as outfile:
448 try: 449 if call is not None:
449 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1, preexec_fn=preexec_fn) 450 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1, preexec_fn=preexec_fn)
450 except NameError: 451 else:
451 try: 452 try:
452 try: 453 try:
453 case.process = Popen(case.problem.config.path, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1, preexec_fn=preexec_fn) 454 case.process = Popen(case.problem.config.path, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1, preexec_fn=preexec_fn)
454 except MemoryError: 455 except MemoryError:
455 # If there is not enough memory for the forked test.py, 456 # If there is not enough memory for the forked test.py,
497 case.has_called_back = True 498 case.has_called_back = True
498 outfile.seek(0) 499 outfile.seek(0)
499 return case.validate(outfile) 500 return case.validate(outfile)
500 else: 501 else:
501 case.infile.copy(case.problem.config.inname) 502 case.infile.copy(case.problem.config.inname)
502 try: 503 if call is not None:
503 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT, preexec_fn=preexec_fn) 504 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT, preexec_fn=preexec_fn)
504 except NameError: 505 else:
505 try: 506 try:
506 try: 507 try:
507 case.process = Popen(case.problem.config.path, stdin=devnull, stdout=devnull, stderr=STDOUT, preexec_fn=preexec_fn) 508 case.process = Popen(case.problem.config.path, stdin=devnull, stdout=devnull, stderr=STDOUT, preexec_fn=preexec_fn)
508 except MemoryError: 509 except MemoryError:
509 # If there is not enough memory for the forked test.py, 510 # If there is not enough memory for the forked test.py,