Mercurial > ~astiob > upreckon > hgweb
comparison 2.00/testcases.py @ 39:2b459f9743b4
Test groups are now supported
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 03 Dec 2010 02:46:06 +0000 |
parents | dc4be35d17e0 |
children | 164395af969d |
comparison
equal
deleted
inserted
replaced
38:a6d554679ce8 | 39:2b459f9743b4 |
---|---|
486 | 486 |
487 def load_problem(prob, _types={'batch' : BatchTestCase, | 487 def load_problem(prob, _types={'batch' : BatchTestCase, |
488 'outonly' : OutputOnlyTestCase, | 488 'outonly' : OutputOnlyTestCase, |
489 'bestout' : BestOutputTestCase, | 489 'bestout' : BestOutputTestCase, |
490 'reactive': ReactiveTestCase}): | 490 'reactive': ReactiveTestCase}): |
491 # We will need to iterate over these configuration variables twice | |
492 try: | |
493 len(prob.config.dummies) | |
494 except Exception: | |
495 prob.config.dummies = tuple(prob.config.dummies) | |
496 try: | |
497 len(prob.config.tests) | |
498 except Exception: | |
499 prob.config.tests = tuple(prob.config.tests) | |
500 | |
491 if options.legacy: | 501 if options.legacy: |
492 prob.config.usegroups = False | 502 prob.config.usegroups = False |
493 prob.config.tests = list(prob.config.tests) | 503 prob.config.tests = list(prob.config.tests) |
494 for i, name in enumerate(prob.config.tests): | 504 for i, name in enumerate(prob.config.tests): |
505 # Same here; we'll need to iterate over them twice | |
495 try: | 506 try: |
496 if len(name) > 1: | 507 l = len(name) |
497 prob.config.usegroups = True | |
498 break | |
499 elif len(name): | |
500 prob.config.tests[i] = name[0] | |
501 except Exception: | 508 except Exception: |
502 try: | 509 try: |
503 # Try to retrieve the first two test case ID's and cache them on success | 510 name = tuple(name) |
504 prob.config.tests[i] = name = iter(name) | |
505 except TypeError: | 511 except TypeError: |
506 continue | 512 name = (name,) |
507 try: | 513 l = len(name) |
508 try: | 514 if len(name) > 1: |
509 first = next(name) | 515 prob.config.usegroups = True |
510 except NameError: | 516 break |
511 # Python 2.5 lacks the next() built-in | 517 elif not len(name): |
512 first = name.next() | 518 prob.config.tests[i] = (name,) |
513 except StopIteration: | 519 |
514 prob.config.tests[i] = () | 520 # First get prob.cache.padoutput right, |
515 else: | 521 # then yield the actual test cases |
516 try: | 522 for i in prob.config.dummies: |
517 try: | 523 s = 'sample ' + str(i).zfill(prob.config.paddummies) |
518 second = next(name) | 524 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) |
519 except NameError: | |
520 second = name.next() | |
521 except StopIteration: | |
522 prob.config.tests[i] = first | |
523 else: | |
524 prob.config.tests[i] = itertools.chain((first, second), name) | |
525 prob.config.usegroups = True | |
526 break | |
527 if prob.config.usegroups: | 525 if prob.config.usegroups: |
528 # FIXME: test groups should again be supported! | 526 for group in prob.config.tests: |
529 pass | 527 for i in group: |
528 s = str(i).zfill(prob.config.padtests) | |
529 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) | |
530 for i in prob.config.dummies: | |
531 s = str(i).zfill(prob.config.paddummies) | |
532 yield _types[prob.config.kind](prob, s, True, 0) | |
533 for group in prob.config.tests: | |
534 yield problem.TestGroup() | |
535 for i in group: | |
536 s = str(i).zfill(prob.config.padtests) | |
537 yield _types[prob.config.kind](prob, s, False, prob.config.pointmap.get(i, prob.config.pointmap.get(None, prob.config.maxexitcode if prob.config.maxexitcode else 1))) | |
538 yield problem.test_context_end | |
530 else: | 539 else: |
531 # We will need to iterate over these configuration variables twice | |
532 try: | |
533 len(prob.config.dummies) | |
534 except Exception: | |
535 prob.config.dummies = tuple(prob.config.dummies) | |
536 try: | |
537 len(prob.config.tests) | |
538 except Exception: | |
539 prob.config.tests = tuple(prob.config.tests) | |
540 # First get prob.cache.padoutput right | |
541 for i in prob.config.dummies: | |
542 s = 'sample ' + str(i).zfill(prob.config.paddummies) | |
543 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) | |
544 for i in prob.config.tests: | 540 for i in prob.config.tests: |
545 s = str(i).zfill(prob.config.padtests) | 541 s = str(i).zfill(prob.config.padtests) |
546 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) | 542 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) |
547 # Now yield the actual test cases | |
548 for i in prob.config.dummies: | 543 for i in prob.config.dummies: |
549 s = str(i).zfill(prob.config.paddummies) | 544 s = str(i).zfill(prob.config.paddummies) |
550 yield _types[prob.config.kind](prob, s, True, 0) | 545 yield _types[prob.config.kind](prob, s, True, 0) |
551 for i in prob.config.tests: | 546 for i in prob.config.tests: |
552 s = str(i).zfill(prob.config.padtests) | 547 s = str(i).zfill(prob.config.padtests) |