Skip to content

Commit d05f033

Browse files
committed
GraalPy Python unit tests use dedicated helpers to ignore Bytecode DSL/Manual interpreter tests
1 parent 3f9f3ac commit d05f033

File tree

9 files changed

+118
-96
lines changed

9 files changed

+118
-96
lines changed

graalpython/com.oracle.graal.python.test/src/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def get_setuptools(setuptools='setuptools==67.6.1'):
7878
else:
7979
py_executable = setuptools_path / 'bin' / 'python3'
8080
extra_args = []
81-
if sys.implementation.name == "graalpy" and not system_python and __graalpython__.is_bytecode_dsl_interpreter:
82-
extra_args = ['--vm.Dpython.EnableBytecodeDSLInterpreter=true']
81+
if sys.implementation.name == "graalpy" and not system_python and not __graalpython__.is_native:
82+
extra_args += [f'--vm.Dpython.EnableBytecodeDSLInterpreter={str(__graalpython__.is_bytecode_dsl_interpreter).lower()}']
8383
subprocess.run([py_executable, *extra_args, "-m", "pip", "install", "--target", str(setuptools_path), setuptools], check=True)
8484
print('setuptools is installed in %s' % setuptools_path)
8585

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -51,8 +51,8 @@
5151
ARGS = []
5252
if sys.implementation.name == 'graalpy':
5353
ARGS = ['--experimental-options', '--python.EnableDebuggingBuiltins']
54-
if not __graalpython__.is_native and __graalpython__.is_bytecode_dsl_interpreter:
55-
ARGS += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true']
54+
if not __graalpython__.is_native:
55+
ARGS += [f'--vm.Dpython.EnableBytecodeDSLInterpreter={str(__graalpython__.is_bytecode_dsl_interpreter).lower()}']
5656
COMMAND = [sys.executable, *ARGS, str(MODULE_PATH)]
5757

5858

graalpython/com.oracle.graal.python.test/src/tests/test_frame_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
# SOFTWARE.
3939
import os
4040
import sys
41-
41+
from tests import util
4242

4343
# IMPORTANT: DO NOT MOVE!
4444
# This test checks that lineno works on frames,
4545
# it MUST stay on this line!
4646
def test_lineno():
4747
assert sys._getframe(0).f_lineno == 47
4848

49-
if not os.environ.get('BYTECODE_DSL_INTERPRETER'): # Blocked by GR-61955
49+
if not util.IS_BYTECODE_DSL: # Blocked by GR-61955
5050
# IMPORTANT: DO NOT MOVE!
5151
def test_nested_lineno():
5252
def test_nested():

graalpython/com.oracle.graal.python.test/src/tests/test_generators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import os
88
import unittest
9+
from tests import util
910

1011

1112
class ExceptionTest(unittest.TestCase):
@@ -557,7 +558,7 @@ def gen():
557558
assert f.f_globals is globals()
558559
assert f.f_locals == {'a': 1, 'b': 2, 'c': 3}
559560
# TODO GR-61955
560-
if sys.implementation.name != "graalpy" or not __graalpython__.is_bytecode_dsl_interpreter:
561+
if not util.IS_BYTECODE_DSL:
561562
assert f.f_lineno == gen.__code__.co_firstlineno + 5
562563
assert not g.gi_frame
563564

@@ -591,7 +592,7 @@ def gen():
591592
assert f.f_globals is globals()
592593
assert f.f_locals == {'a': 1, 'b': 2}
593594
# TODO GR-61955
594-
if sys.implementation.name != "graalpy" or not __graalpython__.is_bytecode_dsl_interpreter:
595+
if not util.IS_BYTECODE_DSL:
595596
assert f.f_lineno == gen.__code__.co_firstlineno + 3
596597

597598

graalpython/com.oracle.graal.python.test/src/tests/test_pdb.py

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import doctest
4242
import sys
4343
import unittest
44+
from tests import util
4445

4546

4647
# Copied from test_doctest
@@ -69,8 +70,6 @@ def __exit__(self, *exc):
6970
if self.orig_trace:
7071
sys.settrace(self.orig_trace)
7172

72-
73-
@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: FrameSlotTypeException with reparsing")
7473
def doctest_pdb_locals():
7574
"""
7675
Test that locals get synced after breakpoint
@@ -101,63 +100,61 @@ def doctest_pdb_locals():
101100
"""
102101

103102

104-
@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: FrameSlotTypeException with reparsing")
105-
def doctest_pdb_locals_generator():
106-
"""
107-
Test that locals get synced after breakpoint in a generator
108-
109-
>>> def test_function():
110-
... a = 1
111-
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
112-
... a = 2
113-
... yield
114-
115-
>>> with PdbTestInput([
116-
... 'p a',
117-
... 'next',
118-
... 'p a',
119-
... 'continue',
120-
... ]):
121-
... next(test_function())
122-
> <doctest tests.test_pdb.doctest_pdb_locals_generator[0]>(4)test_function()
123-
-> a = 2
124-
(Pdb) p a
125-
1
126-
(Pdb) next
127-
> <doctest tests.test_pdb.doctest_pdb_locals_generator[0]>(5)test_function()
128-
-> yield
129-
(Pdb) p a
130-
2
131-
(Pdb) continue
132-
"""
133-
134-
135-
@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: FrameSlotTypeException with reparsing")
136-
def doctest_pdb_locals_sync_back():
137-
"""
138-
Test that locals set by debugger get propagated back into the frame.
139-
140-
>>> def test_function():
141-
... foo = 1
142-
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
143-
... return foo
144-
145-
>>> with PdbTestInput([
146-
... 'p foo',
147-
... 'foo = 5',
148-
... 'continue',
149-
... ]):
150-
... print(test_function())
151-
> <doctest tests.test_pdb.doctest_pdb_locals_sync_back[0]>(4)test_function()
152-
-> return foo
153-
(Pdb) p foo
154-
1
155-
(Pdb) foo = 5
156-
(Pdb) continue
157-
5
158-
"""
103+
if not util.IS_BYTECODE_DSL:
104+
def doctest_pdb_locals_generator():
105+
"""
106+
Test that locals get synced after breakpoint in a generator
107+
108+
>>> def test_function():
109+
... a = 1
110+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
111+
... a = 2
112+
... yield
113+
114+
>>> with PdbTestInput([
115+
... 'p a',
116+
... 'next',
117+
... 'p a',
118+
... 'continue',
119+
... ]):
120+
... next(test_function())
121+
> <doctest tests.test_pdb.doctest_pdb_locals_generator[0]>(4)test_function()
122+
-> a = 2
123+
(Pdb) p a
124+
1
125+
(Pdb) next
126+
> <doctest tests.test_pdb.doctest_pdb_locals_generator[0]>(5)test_function()
127+
-> yield
128+
(Pdb) p a
129+
2
130+
(Pdb) continue
131+
"""
132+
133+
134+
def doctest_pdb_locals_sync_back():
135+
"""
136+
Test that locals set by debugger get propagated back into the frame.
137+
138+
>>> def test_function():
139+
... foo = 1
140+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
141+
... return foo
142+
143+
>>> with PdbTestInput([
144+
... 'p foo',
145+
... 'foo = 5',
146+
... 'continue',
147+
... ]):
148+
... print(test_function())
149+
> <doctest tests.test_pdb.doctest_pdb_locals_sync_back[0]>(4)test_function()
150+
-> return foo
151+
(Pdb) p foo
152+
1
153+
(Pdb) foo = 5
154+
(Pdb) continue
155+
5
156+
"""
159157

160158

161-
@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: FrameSlotTypeException with reparsing")
162159
def test_run_doctests():
163160
doctest.testmod(sys.modules[__name__], raise_on_error=True)

graalpython/com.oracle.graal.python.test/src/tests/test_repl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import sys
4646
import tempfile
4747
import unittest
48+
from tests import util
4849
from dataclasses import dataclass
4950
from textwrap import dedent
5051

@@ -191,7 +192,7 @@ def test_continuation():
191192
'''))
192193

193194

194-
@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: <interactive> vs <module> in traceback")
195+
@util.skipIfBytecodeDSL("TODO: <interactive> vs <module> in traceback")
195196
def test_exceptions():
196197
validate_repl(dedent("""\
197198
>>> 1 / 0

0 commit comments

Comments
 (0)