Skip to content

Commit e104794

Browse files
authored
Disable tests in Mono depending on gc.collect() (#1847)
* Disable tests in Mono depending on gc.collect() * Skip more tests
1 parent f5bb69b commit e104794

File tree

5 files changed

+48
-9
lines changed

5 files changed

+48
-9
lines changed

Tests/modules/type_related/test_ctypes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import gc
1313
import unittest
1414

15-
from iptest import IronPythonTestCase, is_posix, is_cli, big, myint, run_test
15+
from iptest import IronPythonTestCase, is_posix, is_cli, is_mono, big, myint, run_test
1616

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

33+
if is_mono:
34+
with c: pass # gc.collect() in Mono may return before collection is finished
3335
del c
3436
gc.collect()
3537
arr.append(100)
3638
self.assertEqual(arr[-1], 100)
3739

40+
@unittest.skipIf(is_mono, "gc.collect() in Mono may return before collection is finished")
3841
def test_from_memoryview(self):
3942
arr = array('i', range(16))
4043
with memoryview(arr) as mv:

Tests/test_descr_stdlib.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Run selected tests from test_descr from StdLib
77
##
88

9-
from iptest import is_ironpython, generate_suite, run_test
9+
from iptest import is_ironpython, is_mono, generate_suite, run_test
1010

1111
import test.test_descr
1212

@@ -56,6 +56,14 @@ def load_tests(loader, standard_tests, pattern):
5656

5757
skip_tests = []
5858

59+
if is_mono:
60+
skip_tests += [
61+
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
62+
test.test_descr.ClassPropertiesAndMethods('test_delete_hook'),
63+
test.test_descr.ClassPropertiesAndMethods('test_subtype_resurrection'),
64+
test.test_descr.ClassPropertiesAndMethods('test_weakrefs'),
65+
]
66+
5967
return generate_suite(tests, failing_tests, skip_tests)
6068

6169
else:

Tests/test_io_stdlib.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ def load_tests(loader, standard_tests, pattern):
101101
test.test_io.PyMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered
102102
]
103103

104-
if is_mono:
105-
failing_tests += [
106-
test.test_io.CBufferedRandomTest('test_destructor'), # IndexError: index out of range: 0
107-
]
108-
109104
skip_tests = [
110105
test.test_io.CBufferedWriterTest('test_override_destructor'), # StackOverflowException
111106
test.test_io.CBufferedRandomTest('test_override_destructor'), # StackOverflowException
@@ -144,6 +139,31 @@ def load_tests(loader, standard_tests, pattern):
144139
test.test_io.PyMiscIOTest('test_attributes'), # AssertionError: 'wb+' != 'rb+'
145140
]
146141

142+
if is_mono:
143+
skip_tests += [
144+
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
145+
test.test_io.CBufferedRandomTest('test_destructor'),
146+
test.test_io.CBufferedWriterTest('test_destructor'),
147+
test.test_io.PyBufferedWriterTest('test_destructor'),
148+
test.test_io.PyBufferedRandomTest('test_destructor'),
149+
test.test_io.PyBufferedReaderTest('test_override_destructor'),
150+
test.test_io.PyBufferedWriterTest('test_override_destructor'),
151+
test.test_io.PyBufferedRandomTest('test_override_destructor'),
152+
153+
test.test_io.CTextIOWrapperTest('test_destructor'),
154+
test.test_io.CIOTest('test_IOBase_finalize'),
155+
156+
test.test_io.PyTextIOWrapperTest('test_destructor'),
157+
test.test_io.PyTextIOWrapperTest('test_override_destructor'),
158+
test.test_io.PyIOTest('test_RawIOBase_destructor'),
159+
test.test_io.PyIOTest('test_BufferedIOBase_destructor'),
160+
test.test_io.PyIOTest('test_IOBase_destructor'),
161+
test.test_io.PyIOTest('test_TextIOBase_destructor'),
162+
163+
test.test_io.CMiscIOTest('test_blockingioerror'),
164+
test.test_io.PyMiscIOTest('test_blockingioerror'),
165+
]
166+
147167
return generate_suite(tests, failing_tests, skip_tests)
148168

149169
else:

Tests/test_memoryio_stdlib.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Run selected tests from test_memoryio from StdLib
77
##
88

9-
from iptest import is_ironpython, generate_suite, run_test
9+
from iptest import is_ironpython, is_mono, generate_suite, run_test
1010

1111
import test.test_memoryio
1212

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

28+
if is_mono:
29+
skip_tests += [
30+
# On Mono, gc.collect() may return before collection is finished making some tests unreliable
31+
test.test_memoryio.PyBytesIOTest('test_getbuffer')
32+
]
33+
2834
return generate_suite(tests, failing_tests, skip_tests)
2935

3036
else:

Tests/test_namebinding.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# See the LICENSE file in the project root for more information.
44

55
import sys
6+
import unittest
67

7-
from iptest import IronPythonTestCase, is_cli, path_modifier, run_test
8+
from iptest import IronPythonTestCase, is_cli, is_mono, path_modifier, run_test
89

910
glb = 0
1011
res = ''
@@ -312,6 +313,7 @@ def test_DelBuiltin(self):
312313
self.assertRaises(NameError, DoDelBuiltin)
313314
self.assertRaises(NameError, DoDelBuiltin)
314315

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

0 commit comments

Comments
 (0)