Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable tests in Mono depending on gc.collect() #1847

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading