From 84c534ef77a9975aa0a3b03bffe448e8995ec0a0 Mon Sep 17 00:00:00 2001 From: Bohuslav Kabrda Date: Fri, 8 Nov 2013 13:33:44 +0100 Subject: [PATCH] Disable tests in debug build that are irrelevant and fail because of COUNT_ALLOCS --- 00141-fix-test_gc_with_COUNT_ALLOCS.patch | 22 ------- 00141-fix-tests_with_COUNT_ALLOCS.patch | 70 +++++++++++++++++++++++ python3.spec | 6 +- 3 files changed, 73 insertions(+), 25 deletions(-) delete mode 100644 00141-fix-test_gc_with_COUNT_ALLOCS.patch create mode 100644 00141-fix-tests_with_COUNT_ALLOCS.patch diff --git a/00141-fix-test_gc_with_COUNT_ALLOCS.patch b/00141-fix-test_gc_with_COUNT_ALLOCS.patch deleted file mode 100644 index 337e39e..0000000 --- a/00141-fix-test_gc_with_COUNT_ALLOCS.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -up Python-3.2b2/Lib/test/test_gc.py.fix-test-gc-COUNT_ALLOCS Python-3.2b2/Lib/test/test_gc.py ---- Python-3.2b2/Lib/test/test_gc.py.fix-test-gc-COUNT_ALLOCS 2010-12-28 20:39:40.779059772 -0500 -+++ Python-3.2b2/Lib/test/test_gc.py 2010-12-28 20:41:15.890940017 -0500 -@@ -102,10 +102,16 @@ class GCTests(unittest.TestCase): - del a - self.assertNotEqual(gc.collect(), 0) - del B, C -- self.assertNotEqual(gc.collect(), 0) -+ if hasattr(sys, 'getcounts'): -+ self.assertEqual(gc.collect(), 0) -+ else: -+ self.assertNotEqual(gc.collect(), 0) - A.a = A() - del A -- self.assertNotEqual(gc.collect(), 0) -+ if hasattr(sys, 'getcounts'): -+ self.assertEqual(gc.collect(), 0) -+ else: -+ self.assertNotEqual(gc.collect(), 0) - self.assertEqual(gc.collect(), 0) - - def test_method(self): diff --git a/00141-fix-tests_with_COUNT_ALLOCS.patch b/00141-fix-tests_with_COUNT_ALLOCS.patch new file mode 100644 index 0000000..b60ee69 --- /dev/null +++ b/00141-fix-tests_with_COUNT_ALLOCS.patch @@ -0,0 +1,70 @@ +diff -r e245b0d7209b Lib/test/test_gc.py +--- a/Lib/test/test_gc.py Sun Oct 20 02:01:29 2013 -0700 ++++ b/Lib/test/test_gc.py Fri Nov 08 13:25:29 2013 +0100 +@@ -127,10 +127,16 @@ + del a + self.assertNotEqual(gc.collect(), 0) + del B, C +- self.assertNotEqual(gc.collect(), 0) ++ if hasattr(sys, 'getcounts'): ++ self.assertEqual(gc.collect(), 0) ++ else: ++ self.assertNotEqual(gc.collect(), 0) + A.a = A() + del A +- self.assertNotEqual(gc.collect(), 0) ++ if hasattr(sys, 'getcounts'): ++ self.assertEqual(gc.collect(), 0) ++ else: ++ self.assertNotEqual(gc.collect(), 0) + self.assertEqual(gc.collect(), 0) + + def test_method(self): +@@ -618,6 +624,8 @@ + stderr = run_command(code % "gc.DEBUG_SAVEALL") + self.assertNotIn(b"uncollectable objects at shutdown", stderr) + ++ @unittest.skipIf(hasattr(sys, 'getcounts'), ++ 'types are immortal if COUNT_ALLOCS is used') + def test_gc_main_module_at_shutdown(self): + # Create a reference cycle through the __main__ module and check + # it gets collected at interpreter shutdown. +@@ -632,6 +640,8 @@ + rc, out, err = assert_python_ok('-c', code) + self.assertEqual(out.strip(), b'__del__ called') + ++ @unittest.skipIf(hasattr(sys, 'getcounts'), ++ 'types are immortal if COUNT_ALLOCS is used') + def test_gc_ordinary_module_at_shutdown(self): + # Same as above, but with a non-__main__ module. + with temp_dir() as script_dir: +diff -r e245b0d7209b Lib/test/test_module.py +--- a/Lib/test/test_module.py Sun Oct 20 02:01:29 2013 -0700 ++++ b/Lib/test/test_module.py Fri Nov 08 13:25:29 2013 +0100 +@@ -81,6 +81,8 @@ + gc_collect() + self.assertEqual(f().__dict__["bar"], 4) + ++ @unittest.skipIf(hasattr(sys, 'getcounts'), ++ 'types are immortal if COUNT_ALLOCS is used') + def test_clear_dict_in_ref_cycle(self): + destroyed = [] + m = ModuleType("foo") +@@ -96,6 +98,8 @@ + gc_collect() + self.assertEqual(destroyed, [1]) + ++ @unittest.skipIf(hasattr(sys, 'getcounts'), ++ 'types are immortal if COUNT_ALLOCS is used') + def test_weakref(self): + m = ModuleType("foo") + wr = weakref.ref(m) +@@ -190,6 +194,8 @@ + self.assertEqual(r[:25], "") + ++ @unittest.skipIf(hasattr(sys, 'getcounts'), ++ 'skipping since COUNT_ALLOCS was used, see issue19527') + def test_module_finalization_at_shutdown(self): + # Module globals and builtins should still be available during shutdown + rc, out, err = assert_python_ok("-c", "from test import final_a") diff --git a/python3.spec b/python3.spec index 1382490..09a5bbf 100644 --- a/python3.spec +++ b/python3.spec @@ -345,9 +345,9 @@ Patch140: python3-arm-skip-failing-fragile-test.patch # to be relevant for python3 # 00141 # -# Fix test_gc's test_newinstance case when configured with COUNT_ALLOCS: -# Not yet sent upstream -Patch141: 00141-fix-test_gc_with_COUNT_ALLOCS.patch +# Fix test_gc and test_module tests for case when configured with COUNT_ALLOCS: +# http://bugs.python.org/issue19527 +Patch141: 00141-fix-tests_with_COUNT_ALLOCS.patch # 00143 # # Fix the --with-tsc option on ppc64, and rework it on 32-bit ppc to avoid