Mercurial > ~astiob > upreckon > hgweb
comparison testcases.py @ 112:f0b63838f407 2.00
Fixed a crash due to SIGCHLD interrupting validator output pipe reads
| author | Oleg Oshmyan <chortos@inbox.lv> | 
|---|---|
| date | Fri, 08 Apr 2011 19:24:51 +0300 | 
| parents | 6d6d2c82e776 | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 111:5462291b66d5 | 112:f0b63838f407 | 
|---|---|
| 26 c = time.clock() - c | 26 c = time.clock() - c | 
| 27 if int(c + .5) == 1: | 27 if int(c + .5) == 1: | 
| 28 clock = time.clock | 28 clock = time.clock | 
| 29 else: | 29 else: | 
| 30 clock = time.time | 30 clock = time.time | 
| 31 | |
| 32 class DummySignalIgnorer(object): | |
| 33 def __enter__(self): pass | |
| 34 def __exit__(self, exc_type, exc_value, traceback): pass | |
| 35 signal_ignorer = DummySignalIgnorer() | |
| 31 | 36 | 
| 32 try: | 37 try: | 
| 33 from win32 import * | 38 from win32 import * | 
| 34 except Exception: | 39 except Exception: | 
| 35 from unix import * | 40 from unix import * | 
| 272 case.outfile.copy(case.problem.config.ansname) | 277 case.outfile.copy(case.problem.config.ansname) | 
| 273 try: | 278 try: | 
| 274 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1) | 279 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1) | 
| 275 except OSError: | 280 except OSError: | 
| 276 raise CannotStartValidator(sys.exc_info()[1]) | 281 raise CannotStartValidator(sys.exc_info()[1]) | 
| 277 comment = case.process.communicate()[0].strip() | 282 with signal_ignorer: | 
| 283 comment = case.process.communicate()[0].strip() | |
| 278 match = re.match(r'(?i)(ok|(?:correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment) | 284 match = re.match(r'(?i)(ok|(?:correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment) | 
| 279 if match: | 285 if match: | 
| 280 comment = comment[match.end():] | 286 comment = comment[match.end():] | 
| 281 if not case.problem.config.maxexitcode: | 287 if not case.problem.config.maxexitcode: | 
| 282 if case.process.returncode: | 288 if case.process.returncode: | 
