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

gh-90791: Enable test___all__ on ASAN build #108286

Merged
merged 1 commit into from
Aug 22, 2023
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
33 changes: 25 additions & 8 deletions Lib/test/test___all__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@


if support.check_sanitizer(address=True, memory=True):
# bpo-46633: test___all__ is skipped because importing some modules
# directly can trigger known problems with ASAN (like tk).
raise unittest.SkipTest("workaround ASAN build issues on loading tests "
"like tk")
SKIP_MODULES = frozenset((
# gh-90791: Tests involving libX11 can SEGFAULT on ASAN/MSAN builds.
# Skip modules, packages and tests using '_tkinter'.
'_tkinter',
'tkinter',
'test_tkinter',
'test_ttk',
'test_ttk_textonly',
'idlelib',
'test_idle',
))
else:
SKIP_MODULES = ()


class NoAll(RuntimeError):
Expand Down Expand Up @@ -83,15 +92,23 @@ def walk_modules(self, basedir, modpath):
for fn in sorted(os.listdir(basedir)):
path = os.path.join(basedir, fn)
if os.path.isdir(path):
if fn in SKIP_MODULES:
continue
pkg_init = os.path.join(path, '__init__.py')
if os.path.exists(pkg_init):
yield pkg_init, modpath + fn
for p, m in self.walk_modules(path, modpath + fn + "."):
yield p, m
continue
if not fn.endswith('.py') or fn == '__init__.py':

if fn == '__init__.py':
continue
if not fn.endswith('.py'):
continue
modname = fn.removesuffix('.py')
if modname in SKIP_MODULES:
continue
yield path, modpath + fn[:-3]
yield path, modpath + modname

def test_all(self):
# List of denied modules and packages
Expand Down Expand Up @@ -119,14 +136,14 @@ def test_all(self):
if denied:
continue
if support.verbose:
print(modname)
print(f"Check {modname}", flush=True)
try:
# This heuristic speeds up the process by removing, de facto,
# most test modules (and avoiding the auto-executing ones).
with open(path, "rb") as f:
if b"__all__" not in f.read():
raise NoAll(modname)
self.check_all(modname)
self.check_all(modname)
except NoAll:
ignored.append(modname)
except FailedImport:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_concurrent_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


if support.check_sanitizer(address=True, memory=True):
# bpo-46633: Skip the test because it is too slow when Python is built
# gh-90791: Skip the test because it is too slow when Python is built
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
raise unittest.SkipTest("test too slow on ASAN/MSAN build")

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from test.support import check_sanitizer

if check_sanitizer(address=True, memory=True):
# See gh-90791 for details
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")

# Skip test_idle if _tkinter, tkinter, or idlelib are missing.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_peg_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


if support.check_sanitizer(address=True, memory=True):
# bpo-46633: Skip the test because it is too slow when Python is built
# gh-90791: Skip the test because it is too slow when Python is built
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
raise unittest.SkipTest("test too slow on ASAN/MSAN build")

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


if check_sanitizer(address=True, memory=True):
# See gh-90791 for details
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")

# Skip test if _tkinter wasn't built.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


if support.check_sanitizer(address=True, memory=True):
# bpo-46633: Skip the test because it is too slow when Python is built
# gh-90791: Skip the test because it is too slow when Python is built
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
raise unittest.SkipTest("test too slow on ASAN/MSAN build")

Expand Down