def test_abort_early(self): bq = parallel_build.BuildQueue(['a', 'b', 'c', 'd', 'e', 'f'], self.serial_tracker) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual(0, len(bq.built)) self.assertEqual('f', bq.get_valid_package()) bq.return_built('f') self.assertEqual(1, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual('e', bq.get_valid_package()) bq.return_built('e') self.assertEqual(2, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual('d', bq.get_valid_package()) bq.return_built('d') self.assertEqual(3, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) bq.stop() self.assertTrue(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual(None, bq.get_valid_package())
def test_parallel_build(self): bq = parallel_build.BuildQueue(['a', 'b', 'c', 'd', 'e', 'f'], self.parallel_tracker) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) dependents = ['b', 'c', 'd', 'e', 'f'] count = 0 total = 6 while len(dependents) > 0: result = bq.get_valid_package() done = len(bq.built) pkgs = bq._total_pkgs self.assertTrue(result in dependents) # print result, done, pkgs dependents.remove(result) self.assertEqual(count, done) self.assertEqual(total, pkgs) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) bq.return_built(result) count = count + 1 self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual('a', bq.get_valid_package()) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) bq.return_built('a') self.assertTrue(bq.is_done()) self.assertTrue(bq.succeeded())
def test_abort_early(self): bq = parallel_build.BuildQueue(["a", "b", "c", "d", "e", "f"], self.serial_tracker) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual(0, len(bq.built)) self.assertEqual("f", bq.get_valid_package()) bq.return_built("f") self.assertEqual(1, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual("e", bq.get_valid_package()) bq.return_built("e") self.assertEqual(2, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual("d", bq.get_valid_package()) bq.return_built("d") self.assertEqual(3, len(bq.built)) self.assertFalse(bq.is_done()) self.assertFalse(bq.succeeded()) bq.stop() self.assertTrue(bq.is_done()) self.assertFalse(bq.succeeded()) self.assertEqual(None, bq.get_valid_package())