Mercurial > ~astiob > upreckon > hgweb
comparison testcases.py @ 109:dcabc9eb2fde 2.00
Fixed race condition resulting in calling back twice from TestCase.test
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 08 Apr 2011 17:56:54 +0300 |
parents | 9b41934b2e95 |
children | 8f46e84922f9 6d6d2c82e776 |
comparison
equal
deleted
inserted
replaced
101:b92333120c67 | 109:dcabc9eb2fde |
---|---|
315 with open(inputdatafname) as infile: | 315 with open(inputdatafname) as infile: |
316 with tempfile.TemporaryFile('w+') if options.erase and (not case.validator or callable(case.validator)) else open(case.problem.config.outname, 'w+') as outfile: | 316 with tempfile.TemporaryFile('w+') if options.erase and (not case.validator or callable(case.validator)) else open(case.problem.config.outname, 'w+') as outfile: |
317 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1) | 317 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1) |
318 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: | 318 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: |
319 raise NonZeroExitCode(case.process.returncode) | 319 raise NonZeroExitCode(case.process.returncode) |
320 case.has_called_back = True | |
320 callback() | 321 callback() |
321 case.has_called_back = True | |
322 outfile.seek(0) | 322 outfile.seek(0) |
323 return case.validate(outfile) | 323 return case.validate(outfile) |
324 else: | 324 else: |
325 case.infile.copy(case.problem.config.inname) | 325 case.infile.copy(case.problem.config.inname) |
326 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT) | 326 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT) |
327 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: | 327 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: |
328 raise NonZeroExitCode(case.process.returncode) | 328 raise NonZeroExitCode(case.process.returncode) |
329 case.has_called_back = True | |
329 callback() | 330 callback() |
330 case.has_called_back = True | |
331 with open(case.problem.config.outname, 'rU') as output: | 331 with open(case.problem.config.outname, 'rU') as output: |
332 return case.validate(output) | 332 return case.validate(output) |
333 | 333 |
334 | 334 |
335 # This is the only test case type not executing any programs to be tested | 335 # This is the only test case type not executing any programs to be tested |