Mercurial > ~astiob > upreckon > hgweb
diff 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 |
line wrap: on
line diff
--- a/2.00/testcases.py Fri Dec 03 02:45:56 2010 +0000 +++ b/2.00/testcases.py Fri Dec 03 02:46:06 2010 +0000 @@ -488,63 +488,58 @@ 'outonly' : OutputOnlyTestCase, 'bestout' : BestOutputTestCase, 'reactive': ReactiveTestCase}): + # We will need to iterate over these configuration variables twice + try: + len(prob.config.dummies) + except Exception: + prob.config.dummies = tuple(prob.config.dummies) + try: + len(prob.config.tests) + except Exception: + prob.config.tests = tuple(prob.config.tests) + if options.legacy: prob.config.usegroups = False prob.config.tests = list(prob.config.tests) for i, name in enumerate(prob.config.tests): + # Same here; we'll need to iterate over them twice try: - if len(name) > 1: - prob.config.usegroups = True - break - elif len(name): - prob.config.tests[i] = name[0] + l = len(name) except Exception: try: - # Try to retrieve the first two test case ID's and cache them on success - prob.config.tests[i] = name = iter(name) + name = tuple(name) except TypeError: - continue - try: - try: - first = next(name) - except NameError: - # Python 2.5 lacks the next() built-in - first = name.next() - except StopIteration: - prob.config.tests[i] = () - else: - try: - try: - second = next(name) - except NameError: - second = name.next() - except StopIteration: - prob.config.tests[i] = first - else: - prob.config.tests[i] = itertools.chain((first, second), name) - prob.config.usegroups = True - break + name = (name,) + l = len(name) + if len(name) > 1: + prob.config.usegroups = True + break + elif not len(name): + prob.config.tests[i] = (name,) + + # First get prob.cache.padoutput right, + # then yield the actual test cases + for i in prob.config.dummies: + s = 'sample ' + str(i).zfill(prob.config.paddummies) + prob.cache.padoutput = max(prob.cache.padoutput, len(s)) if prob.config.usegroups: - # FIXME: test groups should again be supported! - pass + for group in prob.config.tests: + for i in group: + s = str(i).zfill(prob.config.padtests) + prob.cache.padoutput = max(prob.cache.padoutput, len(s)) + for i in prob.config.dummies: + s = str(i).zfill(prob.config.paddummies) + yield _types[prob.config.kind](prob, s, True, 0) + for group in prob.config.tests: + yield problem.TestGroup() + for i in group: + s = str(i).zfill(prob.config.padtests) + 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))) + yield problem.test_context_end else: - # We will need to iterate over these configuration variables twice - try: - len(prob.config.dummies) - except Exception: - prob.config.dummies = tuple(prob.config.dummies) - try: - len(prob.config.tests) - except Exception: - prob.config.tests = tuple(prob.config.tests) - # First get prob.cache.padoutput right - for i in prob.config.dummies: - s = 'sample ' + str(i).zfill(prob.config.paddummies) - prob.cache.padoutput = max(prob.cache.padoutput, len(s)) for i in prob.config.tests: s = str(i).zfill(prob.config.padtests) prob.cache.padoutput = max(prob.cache.padoutput, len(s)) - # Now yield the actual test cases for i in prob.config.dummies: s = str(i).zfill(prob.config.paddummies) yield _types[prob.config.kind](prob, s, True, 0)