Skip to content

Commit

Permalink
Disable tests in Mono depending on gc.collect() (#1847)
Browse files Browse the repository at this point in the history
* Disable tests in Mono depending on gc.collect()

* Skip more tests
  • Loading branch information
BCSharp authored Dec 23, 2024
1 parent f5bb69b commit e104794
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Tests/modules/type_related/test_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import gc
import unittest

from iptest import IronPythonTestCase, is_posix, is_cli, big, myint, run_test
from iptest import IronPythonTestCase, is_posix, is_cli, is_mono, big, myint, run_test

class CTypesTest(IronPythonTestCase):
export_error_msg = "Existing exports of data: object cannot be re-sized" if is_cli else "cannot resize an array that is exporting buffers"
Expand All @@ -30,11 +30,14 @@ def test_from_array(self):
self.assertRaisesMessage(BufferError, self.export_error_msg, arr.append, 100)
self.assertRaisesMessage(BufferError, self.export_error_msg, arr.insert, 10, 100)

if is_mono:
with c: pass # gc.collect() in Mono may return before collection is finished
del c
gc.collect()
arr.append(100)
self.assertEqual(arr[-1], 100)

@unittest.skipIf(is_mono, "gc.collect() in Mono may return before collection is finished")
def test_from_memoryview(self):
arr = array('i', range(16))
with memoryview(arr) as mv:
Expand Down
10 changes: 9 additions & 1 deletion Tests/test_descr_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Run selected tests from test_descr from StdLib
##

from iptest import is_ironpython, generate_suite, run_test
from iptest import is_ironpython, is_mono, generate_suite, run_test

import test.test_descr

Expand Down Expand Up @@ -56,6 +56,14 @@ def load_tests(loader, standard_tests, pattern):

skip_tests = []

if is_mono:
skip_tests += [
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
test.test_descr.ClassPropertiesAndMethods('test_delete_hook'),
test.test_descr.ClassPropertiesAndMethods('test_subtype_resurrection'),
test.test_descr.ClassPropertiesAndMethods('test_weakrefs'),
]

return generate_suite(tests, failing_tests, skip_tests)

else:
Expand Down
30 changes: 25 additions & 5 deletions Tests/test_io_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.PyMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered
]

if is_mono:
failing_tests += [
test.test_io.CBufferedRandomTest('test_destructor'), # IndexError: index out of range: 0
]

skip_tests = [
test.test_io.CBufferedWriterTest('test_override_destructor'), # StackOverflowException
test.test_io.CBufferedRandomTest('test_override_destructor'), # StackOverflowException
Expand Down Expand Up @@ -144,6 +139,31 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.PyMiscIOTest('test_attributes'), # AssertionError: 'wb+' != 'rb+'
]

if is_mono:
skip_tests += [
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
test.test_io.CBufferedRandomTest('test_destructor'),
test.test_io.CBufferedWriterTest('test_destructor'),
test.test_io.PyBufferedWriterTest('test_destructor'),
test.test_io.PyBufferedRandomTest('test_destructor'),
test.test_io.PyBufferedReaderTest('test_override_destructor'),
test.test_io.PyBufferedWriterTest('test_override_destructor'),
test.test_io.PyBufferedRandomTest('test_override_destructor'),

test.test_io.CTextIOWrapperTest('test_destructor'),
test.test_io.CIOTest('test_IOBase_finalize'),

test.test_io.PyTextIOWrapperTest('test_destructor'),
test.test_io.PyTextIOWrapperTest('test_override_destructor'),
test.test_io.PyIOTest('test_RawIOBase_destructor'),
test.test_io.PyIOTest('test_BufferedIOBase_destructor'),
test.test_io.PyIOTest('test_IOBase_destructor'),
test.test_io.PyIOTest('test_TextIOBase_destructor'),

test.test_io.CMiscIOTest('test_blockingioerror'),
test.test_io.PyMiscIOTest('test_blockingioerror'),
]

return generate_suite(tests, failing_tests, skip_tests)

else:
Expand Down
8 changes: 7 additions & 1 deletion Tests/test_memoryio_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Run selected tests from test_memoryio from StdLib
##

from iptest import is_ironpython, generate_suite, run_test
from iptest import is_ironpython, is_mono, generate_suite, run_test

import test.test_memoryio

Expand All @@ -25,6 +25,12 @@ def load_tests(loader, standard_tests, pattern):
test.test_memoryio.CStringIOTest('test_instance_dict_leak'), # https://github.com/IronLanguages/ironpython3/issues/1004
]

if is_mono:
skip_tests += [
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
test.test_memoryio.PyBytesIOTest('test_getbuffer')
]

return generate_suite(tests, failing_tests, skip_tests)

else:
Expand Down
4 changes: 3 additions & 1 deletion Tests/test_namebinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# See the LICENSE file in the project root for more information.

import sys
import unittest

from iptest import IronPythonTestCase, is_cli, path_modifier, run_test
from iptest import IronPythonTestCase, is_cli, is_mono, path_modifier, run_test

glb = 0
res = ''
Expand Down Expand Up @@ -312,6 +313,7 @@ def test_DelBuiltin(self):
self.assertRaises(NameError, DoDelBuiltin)
self.assertRaises(NameError, DoDelBuiltin)

@unittest.skipIf(is_mono, "TODO: figure out; the finalizer is called way after WaitForPendingFinalizers")
def test_SimpleTest(self):
"""simple case"""
global res
Expand Down

0 comments on commit e104794

Please sign in to comment.