From 2058cac203397bb34ba4c0a270ac0002581124ee Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Jul 2024 09:29:30 +0530 Subject: [PATCH] Now the test should be fully robust --- kitty_tests/graphics.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kitty_tests/graphics.py b/kitty_tests/graphics.py index cbfce8ae1..e79e87744 100644 --- a/kitty_tests/graphics.py +++ b/kitty_tests/graphics.py @@ -240,8 +240,13 @@ class TestGraphics(BaseTest): dc.small_hole_threshold = small_hole_threshold data = {} + holes_to_create = 2, 4, 6, 8 for i in range(25): self.assertIsNone(add(i, f'{i}' * i)) + if i <= max(holes_to_create): + # We wait here to ensure data is written in order, otherwise the + # holes test below can fail + self.assertTrue(dc.wait_for_write()) self.assertEqual(dc.total_size, sum(map(len, data.values()))) self.assertTrue(dc.wait_for_write()) @@ -250,12 +255,11 @@ class TestGraphics(BaseTest): self.assertEqual(sz, sum(map(len, data.values()))) self.assertFalse(dc.holes()) holes = set() - for x in (2, 4, 6, 8): + for x in holes_to_create: remove(x) holes.add(x) check_data() self.assertRaises(KeyError, dc.get, key_as_bytes(x)) - self.assertTrue(dc.wait_for_write()) self.assertEqual(sz, dc.size_on_disk()) self.assertEqual(holes, {x[1] for x in dc.holes()}) self.assertEqual(sz, dc.size_on_disk())