diff options
Diffstat (limited to 'testrepository/tests/test_testcommand.py')
-rw-r--r-- | testrepository/tests/test_testcommand.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py index ef71df0..605d490 100644 --- a/testrepository/tests/test_testcommand.py +++ b/testrepository/tests/test_testcommand.py @@ -226,9 +226,10 @@ class TestTestCommand(ResourcedTestCase): self.set_config( '[DEFAULT]\ntest_command=foo $IDOPTION\n' 'test_id_option=--load-list $IDFILE\n' - 'group_regex=test\n') + 'group_regex=([^\\.]+\\.)+\n') fixture = self.useFixture(command.get_run_command()) - self.assertEqual('test', fixture.group_regex) + self.assertEqual( + 'pkg.class.', fixture._group_callback('pkg.class.test_method')) def test_extra_args_passed_in(self): ui, command = self.get_test_ui_and_cmd() @@ -371,7 +372,7 @@ class TestTestCommand(ResourcedTestCase): self.assertEqual(1, len(partitions[0])) self.assertEqual(1, len(partitions[1])) - def test_partition_tests_with_group_regex(self): + def test_partition_tests_with_grouping(self): repo = memory.RepositoryFactory().initialise('memory:') result = repo.get_inserter() result.startTestRun() @@ -390,17 +391,26 @@ class TestTestCommand(ResourcedTestCase): 'TestCase2.fast2', 'TestCase4.test', 'testdir.testfile.TestCase5.test']) regex = 'TestCase[0-5]' - group_tags = fixture.filter_test_groups(test_ids, regex) - partitions = fixture.partition_tests(test_ids, 2, group_tags) + def group_id(test_id, regex=re.compile('TestCase[0-5]')): + match = regex.match(test_id) + if match: + return match.group(0) + # There isn't a public way to define a group callback [as yet]. + fixture._group_callback = group_id + partitions = fixture.partition_tests(test_ids, 2) + # Timed groups are deterministic: + self.assertTrue('TestCase2.fast1' in partitions[0]) + self.assertTrue('TestCase2.fast2' in partitions[0]) self.assertTrue('TestCase1.slow' in partitions[1]) self.assertTrue('TestCase1.fast' in partitions[1]) self.assertTrue('TestCase1.fast2' in partitions[1]) - self.assertTrue('TestCase3.test2' in partitions[1]) - self.assertTrue('TestCase3.test1' in partitions[1]) - self.assertTrue('TestCase4.test' in partitions[1]) - self.assertTrue('testdir.testfile.TestCase5.test' in partitions[0]) - self.assertTrue('TestCase2.fast1' in partitions[0]) - self.assertTrue('TestCase2.fast2' in partitions[0]) + # Untimed groups just need to be kept together: + if 'TestCase3.test1' in partitions[0]: + self.assertTrue('TestCase3.test2' in partitions[0]) + if 'TestCase4.test' not in partitions[0]: + self.assertTrue('TestCase4.test' in partitions[1]) + if 'testdir.testfile.TestCase5.test' not in partitions[0]: + self.assertTrue('testdir.testfile.TestCase5.test' in partitions[1]) def test_run_tests_with_instances(self): # when there are instances and no instance_execute, run_tests acts as |