8000 Run unittests by palaviv · Pull Request #1650 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Run unittests #1650

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

Merged
merged 9 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Change test code to allow running
  • Loading branch information
palaviv committed Dec 30, 2019
commit 4c7c5fd2250965f1cb92fb53f78a742094e7ce0b
5 changes: 3 additions & 2 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,9 @@ def _test_forever(self, tests):
def display_header(self):
# Print basic platform information
print("==", platform.python_implementation(), *sys.version.split())
print("==", platform.platform(aliased=True),
"%s-endian" % sys.byteorder)
# TODO: Add platform.platform
# print("==", platform.platform(aliased=True),
# "%s-endian" % sys.byteorder)
print("== cwd:", os.getcwd())
cpu_count = os.cpu_count()
if cpu_count:
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/libregrtest/refleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ def clear_caches():
except KeyError:
pass
else:
struct._clearcache()
# TODO: fix
# struct._clearcache()
pass

try:
doctest = sys.modules['doctest']
Expand Down
46 changes: 23 additions & 23 deletions Lib/test/libregrtest/runtest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import collections
import faulthandler
import functools
import gc
# import gc
import importlib
import io
import os
Expand Down Expand Up @@ -44,16 +44,16 @@
# small set of tests to determine if we have a basically functioning interpreter
# (i.e. if any of these fail, then anything else is likely to follow)
STDTESTS = [
'test_grammar',
'test_opcodes',
'test_dict',
'test_builtin',
'test_exceptions',
'test_types',
'test_unittest',
'test_doctest',
'test_doctest2',
'test_support'
# 'test_grammar',
# 'test_opcodes',
# 'test_dict',
# 'test_builtin',
# 'test_exceptions',
# 'test_types',
# 'test_unittest',
# 'test_doctest',
# 'test_doctest2',
# 'test_support'
]

# set of tests that we don't want to be executed when using regrtest
Expand Down Expand Up @@ -223,15 +223,15 @@ def _runtest_inner2(ns, test_name):

support.gc_collect()

if gc.garbage:
support.environment_altered = True
print_warning(f"{test_name} created {len(gc.garbage)} "
f"uncollectable object(s).")
# if gc.garbage:
# support.environment_altered = True
# print_warning(f"{test_name} created {len(gc.garbage)} "
# f"uncollectable object(s).")

# move the uncollectable objects somewhere,
# so we don't see them again
FOUND_GARBAGE.extend(gc.garbage)
gc.garbage.clear()
# # move the uncollectable objects somewhere,
# # so we don't see them again
# FOUND_GARBAGE.extend(gc.garbage)
# gc.garbage.clear()

support.reap_children()

Expand All @@ -251,8 +251,8 @@ def _runtest_inner(ns, test_name, display_failure=True):
try:
clear_caches()

with saved_test_environment(test_name, ns.verbose, ns.quiet, pgo=ns.pgo) as environment:
refleak = _runtest_inner2(ns, test_name)
# with saved_test_environment(test_name, ns.verbose, ns.quiet, pgo=ns.pgo) as environment:
refleak = _runtest_inner2(ns, test_name)
except support.ResourceDenied as msg:
if not ns.quiet and not ns.pgo:
print(f"{test_name} skipped -- {msg}", flush=True)
Expand Down Expand Up @@ -281,8 +281,8 @@ def _runtest_inner(ns, test_name, display_failure=True):

if refleak:
return FAILED
if environment.changed:
return ENV_CHANGED
# if environment.changed:
# return ENV_CHANGED
return PASSED


Expand Down
4 changes: 2 additions & 2 deletions Lib/test/libregrtest/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def setup_tests(ns):
for signum in signals:
faulthandler.register(signum, chain=True, fil 8000 e=stderr_fd)

replace_stdout()
support.record_original_stdout(sys.stdout)
# replace_stdout()
# support.record_original_stdout(sys.stdout)

if ns.testdir:
# Prepend test directory to sys.path, so runtest() will be able
Expand Down
90 changes: 46 additions & 44 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,38 +896,38 @@ def dec(*args, **kwargs):
TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE)
TESTFN_ENCODING = sys.getfilesystemencoding()

# TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
# encoded by the filesystem encoding (in strict mode). It can be None if we
# cannot generate such filename.
TESTFN_UNENCODABLE = None
if os.name == 'nt':
# skip win32s (0) or Windows 9x/ME (1)
if sys.getwindowsversion().platform >= 2:
# Different kinds of characters from various languages to minimize the
# probability that the whole name is encodable to MBCS (issue #9819)
TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80"
try:
TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
except UnicodeEncodeError:
pass
else:
print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
'Unicode filename tests may not be effective'
% (TESTFN_UNENCODABLE, TESTFN_ENCODING))
TESTFN_UNENCODABLE = None
# Mac OS X denies unencodable filenames (invalid utf-8)
elif sys.platform != 'darwin':
try:
# ascii and utf-8 cannot encode the byte 0xff
b'\xff'.decode(TESTFN_ENCODING)
except UnicodeDecodeError:
# 0xff will be encoded using the surrogate character u+DCFF
TESTFN_UNENCODABLE = TESTFN \
+ b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
else:
# File system encoding (eg. ISO-8859-* encodings) can encode
# the byte 0xff. Skip some unicode filename tests.
pass
# # TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
# # encoded by the filesystem encoding (in strict mode). It can be None if we
# # cannot generate such filename.
# TESTFN_UNENCODABLE = None
# if os.name == 'nt':
# # skip win32s (0) or Windows 9x/ME (1)
# if sys.getwindowsversion().platform >= 2:
# # Different kinds of characters from various languages to minimize the
# # probability that the whole name is encodable to MBCS (issue #9819)
# TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80"
# try:
# TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
# except UnicodeEncodeError:
# pass
# else:
# print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
# 'Unicode filename tests may not be effective'
# % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
# TESTFN_UNENCODABLE = None
# # Mac OS X denies unencodable filenames (invalid utf-8)
# elif sys.platform != 'darwin':
# try:
# # ascii and utf-8 cannot encode the byte 0xff
# b'\xff'.decode(TESTFN_ENCODING)
# except UnicodeDecodeError:
# # 0xff will be encoded using the surrogate character u+DCFF
# TESTFN_UNENCODABLE = TESTFN \
# + b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
# else:
# # File system encoding (eg. ISO-8859-* encodings) can encode
# # the byte 0xff. Skip some unicode filename tests.
# pass

# # TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be
# # decoded from the filesystem encoding (in strict mode). It can be None if we
Expand Down Expand Up @@ -1624,21 +1624,23 @@ def gc_collect():
longer than expected. This function tries its best to force all garbage
objects to disappear.
"""
gc.collect()
if is_jython:
time.sleep(0.1)
gc.collect()
gc.collect()
# gc.collect()
# if is_jython:
# time.sleep(0.1)
# gc.collect()
# gc.collect()
pass

@contextlib.contextmanager
def disable_gc():
have_gc = gc.isenabled()
gc.disable()
try:
yield
finally:
if have_gc:
gc.enable()
# have_gc = gc.isenabled()
# gc.disable()
# try:
# yield
# finally:
# if have_gc:
# gc.enable()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably still yield here, since it's a context manager. Unless @contextlib.contextmanager works with non-generators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

pass


def python_is_optimized():
Expand Down
0