def _execute_tasks(self, max_number_of_test_cases,
                       max_number_of_tests_per_test_case,
                       max_number_of_repeats, max_number_of_workers,
                       serialize_test_cases):
        tasks = []
        for test_case in range(max_number_of_test_cases):
            for test_name in range(max_number_of_tests_per_test_case):
                # All arguments for gtest_parallel.Task except for test_name are fake.
                test_name = 'TestCase{}.test{}'.format(test_case, test_name)

                for execution_number in range(
                        random.randint(1, max_number_of_repeats)):
                    tasks.append(
                        gtest_parallel.Task(
                            'path/to/binary', test_name,
                            ['path/to/binary', '--gtest_filter=*'],
                            execution_number + 1, None, 'path/to/output'))

        expected_tasks_number = len(tasks)

        task_manager = TaskManagerMock()

        gtest_parallel.execute_tasks(tasks, max_number_of_workers,
                                     task_manager, None, serialize_test_cases)

        self.assertEqual(serialize_test_cases,
                         not task_manager.had_running_parallel_groups)
        self.assertEqual(expected_tasks_number, task_manager.total_tasks_run)
Example #2
0
    def run_test(_):
      task = gtest_parallel.Task('fake/binary', 'test', ['fake/binary'],
                                 1, None, None)

      self.assertTrue(os.path.isfile(task.log_file))

      task.run()

      self.assertTrue(os.path.isfile(task.log_file))
      self.assertIsNone(task.exit_code)
Example #3
0
    def run_test(temp_dir):
      task = gtest_parallel.Task('fake/binary', 'test', ['fake/binary'],
                                 1, None, temp_dir)

      self.assertFalse(os.path.isfile(task.log_file))

      task.run()

      self.assertTrue(os.path.isfile(task.log_file))
      self.assertEqual(42, task.exit_code)