Skip to content

Commit

Permalink
Tests: Shell: Skip on ASan CI runs
Browse files Browse the repository at this point in the history
Also:
* Tests: Shell: Consolidate/eliminate use of @skip_on_windows
  • Loading branch information
davidfstr committed Jul 17, 2024
1 parent e84d7ff commit fa74b4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
3 changes: 0 additions & 3 deletions src/crystal/tests/test_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
crystal_shell,
)
from crystal.tests.util.windows import OpenOrCreateDialog
from crystal.tests.util.xos import skip_on_windows
import tempfile
import textwrap

Expand All @@ -17,8 +16,6 @@ async def test_can_close_project_with_menuitem() -> None:


async def test_can_quit_with_menuitem() -> None:
skip_on_windows()() # crystal_shell doesn't support Windows

with crystal_shell() as (crystal, _):
_create_new_empty_project(crystal)

Expand Down
32 changes: 18 additions & 14 deletions src/crystal/tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from crystal.tests.util.windows import MainWindow
from crystal.tests.util.screenshots import take_error_screenshot
from crystal.tests.util.server import served_project
from crystal.tests.util.skip import skipTest
from crystal.tests.util.subtests import SubtestsContext, with_subtests
from crystal.tests.util.xos import skip_on_windows
from crystal.util.xos import is_windows
from crystal.util.xos import is_asan, is_windows
from crystal.util.xthreading import fg_call_and_wait
from functools import wraps
from io import StringIO, TextIOBase
Expand Down Expand Up @@ -74,7 +74,6 @@
# ------------------------------------------------------------------------------
# Tests

@skip_on_windows
@with_subtests
def test_can_launch_with_shell(subtests: SubtestsContext) -> None:
with crystal_shell() as (crystal, banner):
Expand Down Expand Up @@ -124,7 +123,6 @@ def test_can_launch_with_shell(subtests: SubtestsContext) -> None:
assertIn('Help on MainWindow in module crystal.browser object:', _py_eval(crystal, 'help(window)'))


@skip_on_windows
def test_can_use_pythonstartup_file() -> None:
with tempfile.NamedTemporaryFile(suffix='.py') as startup_file:
startup_file.write(textwrap.dedent('''\
Expand All @@ -145,7 +143,6 @@ def test_can_use_pythonstartup_file() -> None:
# NOTE: This test code was split out of the test_can_launch_with_shell() test above
# because it is particularly easy to break and having a separate test function
# makes the break type quicker to identify.
@skip_on_windows
@with_subtests
def test_builtin_globals_have_stable_public_api(subtests: SubtestsContext) -> None:
with crystal_shell() as (crystal, _):
Expand All @@ -163,9 +160,10 @@ def test_builtin_globals_have_stable_public_api(subtests: SubtestsContext) -> No
'Public API of MainWindow class has changed')


@skip_on_windows
@with_subtests
def test_shell_exits_with_expected_message(subtests: SubtestsContext) -> None:
_ensure_can_use_crystal_shell()

with subtests.test(case='test when first open/create dialog is closed given shell is running then shell remains running'):
with crystal_shell() as (crystal, _):
_close_open_or_create_dialog(crystal)
Expand Down Expand Up @@ -291,7 +289,6 @@ def test_shell_exits_with_expected_message(subtests: SubtestsContext) -> None:
timeout=.5 + DEFAULT_WAIT_TIMEOUT)


@skip_on_windows
def test_when_typed_code_raises_exception_then_print_traceback() -> None:
with crystal_shell() as (crystal, _):
expected_traceback = (
Expand All @@ -302,7 +299,6 @@ def test_when_typed_code_raises_exception_then_print_traceback() -> None:
assertEqual(expected_traceback, _py_eval(crystal, 'Resource'))


@skip_on_windows
@with_subtests
def test_can_read_project_with_shell(subtests: SubtestsContext) -> None:
with served_project('testdata_xkcd.crystalproj.zip') as sp:
Expand Down Expand Up @@ -394,7 +390,6 @@ def test_can_read_project_with_shell(subtests: SubtestsContext) -> None:
assertIn(b'<title>xkcd: Air Gap</title>', response_bytes)


@skip_on_windows
@with_subtests
def test_can_write_project_with_shell(subtests: SubtestsContext) -> None:
with served_project('testdata_xkcd.crystalproj.zip') as sp:
Expand Down Expand Up @@ -565,7 +560,6 @@ def test_can_delete_project_entities() -> None:
pass


@skip_on_windows
def test_can_import_guppy_in_shell() -> None:
with crystal_shell() as (crystal, _):
# Ensure can import guppy
Expand Down Expand Up @@ -707,10 +701,7 @@ def crystal_shell(*, env_extra={}) -> Iterator[Tuple[subprocess.Popen, str]]:
Context which starts "crystal --shell" upon enter
and cleans up the associated process upon exit.
"""
if platform.system() == 'Windows':
# Windows doesn't provide stdout for graphical processes,
# which is needed by the current implementation
raise AssertionError('not supported on Windows')
_ensure_can_use_crystal_shell()

# Determine how to run Crystal on command line
crystal_command: List[str]
Expand Down Expand Up @@ -762,6 +753,19 @@ def crystal_shell(*, env_extra={}) -> Iterator[Tuple[subprocess.Popen, str]]:
crystal.wait()


def _ensure_can_use_crystal_shell() -> None:
if is_windows():
# NOTE: Windows doesn't provide stdout for graphical processes,
# which is needed by the current implementation.
# Workaround is possible with run_exe.py but time-consuming to implement.
skipTest('not supported on Windows; graphical subprocesses are mute')
if is_asan():
# NOTE: ASan slows down many operations, causing shell operations to
# spuriously fail timeout checks, even when
# CRYSTAL_GLOBAL_TIMEOUT_MULTIPLIER is used
skipTest('too slow when run with Address Sanitizer')


def _py_eval(
python: subprocess.Popen,
py_code: str,
Expand Down
21 changes: 0 additions & 21 deletions src/crystal/tests/util/xos.py

This file was deleted.

0 comments on commit fa74b4c

Please sign in to comment.