[pypy-commit] lang-smalltalk storage-cleanups: Tagged some tests with @slow_tests, which excludes them from regular execution.
anton_gulenko
noreply at buildbot.pypy.org
Wed Aug 6 19:46:58 CEST 2014
Author: Anton Gulenko <anton.gulenko at googlemail.com>
Branch: storage-cleanups
Changeset: r1025:f0f40bb06fc8
Date: 2014-08-06 16:55 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/f0f40bb06fc8/
Log: Tagged some tests with @slow_tests, which excludes them from regular
execution. Adding --slow parameter to pytest executes all tests. The
fast tests take 12 seconds, the entire test suite takes 2:30
minutes. Most of the time is spent in 2-3 tests. Maybe add something
like @very_slow_test? Also split test_miniimage.py in two files.
diff --git a/spyvm/test/conftest.py b/spyvm/test/conftest.py
new file mode 100644
--- /dev/null
+++ b/spyvm/test/conftest.py
@@ -0,0 +1,25 @@
+import py
+
+def pytest_addoption(parser):
+ group = parser.getgroup("RSqueak test options")
+ group.addoption(
+ "--slow", "-S",
+ dest="execute-slow-tests",
+ action="store_true",
+ default=False,
+ help="Additionally execute slow tests (loading full Squeak image or long execution)"
+ )
+ group.addoption(
+ "--jit",
+ dest="rsqueak-binary",
+ action="store",
+ default=None,
+ help="Path to a compiled rsqueak binary"
+ )
+
+# The 'spy' parameter is used in tests under jittest/
+def pytest_funcarg__spy(request):
+ val = request.config.getvalue("rsqueak-binary")
+ if not val:
+ py.test.skip("Provide --jit parameter to execute jit tests")
+ return str(py.path.local(val))
diff --git a/spyvm/test/jittest/conftest.py b/spyvm/test/jittest/conftest.py
deleted file mode 100644
--- a/spyvm/test/jittest/conftest.py
+++ /dev/null
@@ -1,15 +0,0 @@
-import py
-
-
-def pytest_addoption(parser):
- group = parser.getgroup("SPy JIT tests")
- group.addoption(
- "--spy",
- dest="spy",
- default=None,
- help="Path to a compiled SPy binary"
- )
-
-
-def pytest_funcarg__spy(request):
- return str(py.path.local(request.config.getvalueorskip("spy")))
diff --git a/spyvm/test/test_bootstrappedimage.py b/spyvm/test/test_bootstrappedimage.py
--- a/spyvm/test/test_bootstrappedimage.py
+++ b/spyvm/test/test_bootstrappedimage.py
@@ -1,12 +1,11 @@
import py
-from .util import read_image, copy_to_module, cleanup_module
+from .util import read_image, copy_to_module, cleanup_module, slow_test
def setup_module():
space, interp, image, reader = read_image("bootstrapped.image")
w = space.w
perform = interp.perform
copy_to_module(locals(), __name__)
- space.initialize_class(space.w_String, interp)
def teardown_module():
cleanup_module(__name__)
@@ -15,6 +14,7 @@
w_result = perform(image.w_asSymbol, "asSymbol")
assert w_result is image.w_asSymbol
+ at slow_test
def test_retrieve_symbol():
"""asSymbol
"This is the only place that new Symbols are created. A Symbol is created
@@ -25,6 +25,7 @@
ifTrue: [ ^ sym ] ].
^ (Symbol basicNew: self size) initFrom: self"""
+ space.initialize_class(space.w_String, interp)
w_result = perform(w("someString"), "asSymbol")
assert w_result.as_string() == "someString"
w_anotherSymbol = perform(w("someString"), "asSymbol")
@@ -32,6 +33,4 @@
def test_all_pointers_are_valid():
from test_miniimage import _test_all_pointers_are_valid
- from test_miniimage import _test_lookup_abs_in_integer
_test_all_pointers_are_valid(reader)
- _test_lookup_abs_in_integer(interp)
diff --git a/spyvm/test/test_largeinteger.py b/spyvm/test/test_largeinteger.py
--- a/spyvm/test/test_largeinteger.py
+++ b/spyvm/test/test_largeinteger.py
@@ -1,7 +1,7 @@
import operator
from spyvm import model, constants, primitives
from spyvm.test.test_primitives import MockFrame
-from .util import read_image, copy_to_module, cleanup_module
+from .util import read_image, copy_to_module, cleanup_module, slow_test
from rpython.rlib.rarithmetic import intmask, r_uint
def setup_module():
@@ -9,7 +9,6 @@
w = space.w
copy_to_module(locals(), __name__)
interp.trace = False
- space.initialize_class(space.w_String, interp)
def teardown_module():
cleanup_module(__name__)
@@ -71,14 +70,4 @@
return a >> -b
else:
return a << b
-# do_primitive("bitShift:", shift, j=-5)
- do_primitive("bitShift:", shift, i=[9470032], j=[6]) # 8
-
-# def test_primitiveAdd():
-# do_primitive("+", operator.add)
-
-# def test_primitiveSub():
-# do_primitive("-", operator.sub, j=[0xFF, 0xFFFF, 0xF0E0D0C0], i=[-1, -1, -1])
-# do_primitive("-", operator.sub)
- # do_primitive("-", operator.sub, i=[0xFF], j=0x3FFFFFFF)
-
+ do_primitive("bitShift:", shift, i=[9470032], j=[6])
diff --git a/spyvm/test/test_miniimage.py b/spyvm/test/test_miniimage.py
--- a/spyvm/test/test_miniimage.py
+++ b/spyvm/test/test_miniimage.py
@@ -1,6 +1,6 @@
import py, math
from spyvm import model, constants, storage_contexts, wrapper, primitives, interpreter, error
-from .util import read_image, open_reader, copy_to_module, cleanup_module, TestInterpreter
+from .util import read_image, open_reader, copy_to_module, cleanup_module, TestInterpreter, slow_test
def setup_module():
space, interp, image, reader = read_image("mini.image")
@@ -14,35 +14,32 @@
def teardown_module():
cleanup_module(__name__)
-def open_miniimage():
- return open_reader(space, "mini.image")
+def runningSomethingImage(cached=True):
+ # This image has been created by executing the followin entire line in a workspace:
+ # a := Smalltalk snapshotPrimitive. 1+2.
+ # This way, the first few operations when opening this image are predetermined.
+ space, interp, _, _ = read_image('mini-running-something.image', cached=cached)
+ return space, interp
-def find_symbol(name):
- if name == "asSymbol":
- return image.w_asSymbol
- return perform(space.wrap_string(name), "asSymbol")
-
-def get_reader():
- return reader
-
-def get_image():
- return image
+def runningExitImage(cached=True):
+ # This image has been created by executing the followin entire line in a workspace:
+ # Smalltalk snapshotPrimitive. Smalltalk snapshot: false andQuit: true.
+ # After starting, the image quits immediately. This allows testing the full image execution.
+ space, interp, _, _ = read_image('mini-running-exit.image', cached=cached)
+ return space, interp
def get_float_class():
- image = get_image()
return image.special(constants.SO_FLOAT_CLASS)
-
+
# ------ tests ------------------------------------------
def test_read_header():
- reader = open_miniimage()
- reader.read_header()
assert reader.endofmemory == 726592
assert reader.oldbaseaddress == -1221464064
assert reader.specialobjectspointer == -1221336216
def test_read_all_header():
- reader = open_miniimage()
+ reader = open_reader(space, "mini.image")
reader.read_header()
next = reader.stream.peek()
assert next != 0 #expects object header, which must not be 0x00000000
@@ -55,11 +52,9 @@
assert pointer in reader.chunks
def test_all_pointers_are_valid():
- reader = get_reader()
_test_all_pointers_are_valid(reader)
def test_there_are_31_compact_classes():
- reader = get_reader()
assert len(reader.compactclasses) == 31
def test_float_class_size():
@@ -98,7 +93,6 @@
assert str(w_float_class.getclass(space).getclass(space).getclass(space)) == "Metaclass class"
def test_nil_true_false():
- image = get_image()
w = image.special(constants.SO_NIL)
w.class_shadow(space)
assert str(w) == "a UndefinedObject"
@@ -110,7 +104,6 @@
assert str(w) == "a True"
def test_scheduler():
- image = get_image()
w = image.special(constants.SO_SCHEDULERASSOCIATIONPOINTER)
w0 = w.fetch(space, 0)
assert str(w0) == "a Symbol('Processor')"
@@ -123,7 +116,6 @@
obj = image.special(so_index)
obj.as_class_get_shadow(space)
assert str(obj) == expected_name
- image = get_image()
# w = image.special(constants.SO_BITMAP_CLASS)
# assert str(w) == "Bitmap"
test_classname(constants.SO_SMALLINTEGER_CLASS, "SmallInteger")
@@ -146,7 +138,6 @@
SO_CHARACTER_CLASS = 19"""
def test_name_of_shadow_of_specials():
- image = get_image()
w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
assert repr(w_doesnot.class_shadow(space)) == "<ClassShadow Symbol>"
assert repr(space.w_nil.class_shadow(space)) == "<ClassShadow UndefinedObject>"
@@ -158,7 +149,6 @@
assert repr(space.w_false.class_shadow(space)) == "<ClassShadow False>"
def test_special_objects0():
- image = get_image()
w = image.special(constants.SO_DOES_NOT_UNDERSTAND)
assert str(w) == "a Symbol('doesNotUnderstand:')"
assert str(w.getclass(space)) == "Symbol" # for some strange reason not a symbol
@@ -210,80 +200,29 @@
w_false = image.special(constants.SO_FALSE)
assert w_false.is_same_object(space.w_false)
+ at slow_test
def test_runimage_and_quit():
- # This image has been prepared executing the following DoIt (the entire line):
- # Smalltalk snapshotPrimitive. Smalltalk snapshot: false andQuit: true.
- # After starting, the image quits immediately. This allows testing the full image execution.
-
from targetimageloadingsmalltalk import active_context, execute_context
- space, interp, _, _ = read_image('mini-running-exit.image')
+ space, interp = runningExitImage(cached=False)
frame = active_context(space)
try:
execute_context(interp, frame)
except error.Exit, e:
assert e.msg == "Quit-Primitive called"
-def test_compile_method():
- sourcecode = """fib
- ^self < 2
- ifTrue: [ 1 ]
- ifFalse: [ (self - 1) fib + (self - 2) fib ]"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- assert perform(w(10), "fib").is_same_object(w(89))
-
-def test_become():
- sourcecode = """
- testBecome
- | p1 p2 a |
- p1 := 1 at 2.
- p2 := #(3 4 5).
- a := p1 -> p2.
- (1 at 2 = a key) ifFalse: [^1].
- (#(3 4 5) = a value) ifFalse: [^2].
- (p1 -> p2 = a) ifFalse: [^3].
- (p1 == a key) ifFalse: [^4].
- (p2 == a value) ifFalse: [^5].
- p1 become: p2.
- (1 at 2 = a value) ifFalse: [^6].
- (3 = (a key at: 1)) ifFalse: [^7].
- (4 = (a key at: 2)) ifFalse: [^8].
- (5 = (a key at: 3)) ifFalse: [^9].
- (p1 -> p2 = a) ifFalse: [^10].
- (p1 == a key) ifFalse: [^11].
- (p2 == a value) ifFalse: [^12].
-
- ^42"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- w_result = perform(w(10), "testBecome")
- assert space.unwrap_int(w_result) == 42
-
def test_step_forged_image():
ap = wrapper.ProcessWrapper(space, wrapper.scheduler(space).active_process())
s_ctx = ap.suspended_context().as_context_get_shadow(space)
assert isinstance(s_ctx, storage_contexts.MethodContextShadow)
assert s_ctx.top().is_same_object(space.w_true)
-def test_cached_methoddict():
- sourcecode = """fib
- ^self < 2
- ifTrue: [ 1 ]
- ifFalse: [ ((self - 1) fib + (self - 2) fib) + 1 ]"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- assert perform(w(5), "fib").is_same_object(w(15))
- sourcecode = """fib
- ^self < 2
- ifTrue: [ 1 ]
- ifFalse: [ (self - 1) fib + (self - 2) fib ]"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- assert perform(w(10), "fib").is_same_object(w(89))
-
def test_create_new_symbol():
w_result = perform(w("someString"), "asSymbol")
assert w_result is not None
assert w_result.as_string() == "someString"
def test_create_new_symbol_new_with_arg0():
- w_dnu = get_image().special(constants.SO_DOES_NOT_UNDERSTAND)
+ w_dnu = image.special(constants.SO_DOES_NOT_UNDERSTAND)
w_Symbol = w_dnu.getclass(space)
w_res = perform(w_Symbol, "new:", w(0))
assert w_res.getclass(space).is_same_object(w_Symbol)
@@ -301,14 +240,6 @@
assert w_result is not None
assert isinstance(w_result, model.W_Float)
-def test_compiling_float():
- sourcecode = """aFloat
- ^ 1.1"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- w_result = perform(w(10), "aFloat")
- assert isinstance(w_result, model.W_Float)
- assert w_result.value == 1.1
-
def test_existing_large_positive_integer_as_W_LargePositiveInteger1Word():
w_result = perform(interp.space.w_Float, "pi")
assert w_result is not None
@@ -326,13 +257,6 @@
assert w_result is not None
assert isinstance(w_result, model.W_BytesObject)
-def test_compiling_large_positive_integer():
- sourcecode = """aLargeInteger
- ^ 16rFFFFFFFF"""
- perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
- w_result = perform(w(10), "aLargeInteger")
- assert isinstance(w_result, model.W_LargePositiveInteger1Word)
-
def test_doesNotUnderstand():
w_dnu = interp.space.objtable["w_doesNotUnderstand"]
assert isinstance(w_dnu, model.W_BytesObject)
@@ -343,18 +267,6 @@
assert isinstance(w_mbb, model.W_BytesObject)
assert w_mbb.as_string() == "mustBeBoolean"
-def test_run_doesNotUnderstand():
- space, interp, _, _ = read_image('mini-running-something.image')
- w_result = interp.perform(interp.space.wrap_int(0), "runningADNU")
- assert isinstance(w_result, model.W_BytesObject)
- assert w_result.as_string() == "foobarThis:doesNotExist:('pypy' 'heya' )"
-
-def test_run_mustBeBoolean():
- space, interp, _, _ = read_image('mini-running-something.image')
- w_result = interp.perform(interp.space.wrap_int(0), "runningMustBeBoolean")
- assert isinstance(w_result, model.W_BytesObject)
- assert w_result.as_string() == "mustBeBoolean has been called"
-
def test_Message():
w_message_cls = interp.space.w_Message
assert w_message_cls is interp.space.classtable["w_Message"]
@@ -364,27 +276,6 @@
w_message = s_message_cls.new()
assert isinstance(w_message, model.W_PointersObject)
-def test_step_run_something():
- # This test depends on the following code being executed in a workspace (the entire line):
- # a := Smalltalk snapshotPrimitive. 1+2.
- # This will save the image in a state that will satisfy the following test.
-
- space, interp, _, _ = read_image('mini-running-something.image')
- ap = wrapper.ProcessWrapper(space, wrapper.scheduler(space).active_process())
- w_ctx = ap.suspended_context()
- s_ctx = w_ctx.as_context_get_shadow(space)
- ap.store_suspended_context(space.w_nil)
-
- assert isinstance(s_ctx, storage_contexts.MethodContextShadow)
- assert s_ctx.top().is_same_object(space.w_true)
- interp.step(s_ctx)
- interp.step(s_ctx)
- assert s_ctx.top().value == 1
- interp.step(s_ctx)
- assert s_ctx.top().value == 2
- interp.step(s_ctx)
- assert s_ctx.top().value == 3
-
def test_primitive_perform_with_args():
from spyvm.test.test_primitives import _prim
w_o = space.wrap_list([1, 2, 3])
@@ -397,3 +288,32 @@
w_sel = sel
size = _prim(space, primitives.PERFORM_WITH_ARGS, [w_o, w_sel, []])
assert size.value == 3
+
+def test_step_run_something():
+ space, interp = runningSomethingImage(cached=False)
+ ap = wrapper.ProcessWrapper(space, wrapper.scheduler(space).active_process())
+ w_ctx = ap.suspended_context()
+ s_ctx = w_ctx.as_context_get_shadow(space)
+ ap.store_suspended_context(space.w_nil)
+
+ assert isinstance(s_ctx, storage_contexts.MethodContextShadow)
+ assert s_ctx.top().is_same_object(space.w_true)
+ interp.step(s_ctx)
+ interp.step(s_ctx)
+ assert s_ctx.top().value == 1
+ interp.step(s_ctx)
+ assert s_ctx.top().value == 2
+ interp.step(s_ctx)
+ assert s_ctx.top().value == 3
+
+def test_run_doesNotUnderstand():
+ space, interp = runningSomethingImage()
+ w_result = interp.perform(interp.space.wrap_int(0), "runningADNU")
+ assert isinstance(w_result, model.W_BytesObject)
+ assert w_result.as_string() == "foobarThis:doesNotExist:('pypy' 'heya' )"
+
+def test_run_mustBeBoolean():
+ space, interp = runningSomethingImage()
+ w_result = interp.perform(interp.space.wrap_int(0), "runningMustBeBoolean")
+ assert isinstance(w_result, model.W_BytesObject)
+ assert w_result.as_string() == "mustBeBoolean has been called"
diff --git a/spyvm/test/test_miniimage_compiling.py b/spyvm/test/test_miniimage_compiling.py
new file mode 100644
--- /dev/null
+++ b/spyvm/test/test_miniimage_compiling.py
@@ -0,0 +1,82 @@
+import py, math
+from spyvm import model, constants, storage_contexts, wrapper, primitives, interpreter, error
+from .util import read_image, open_reader, copy_to_module, cleanup_module, TestInterpreter, slow_test
+
+pytestmark = slow_test
+
+def setup_module():
+ space, interp, _, _ = read_image("mini.image")
+ w = space.w
+ def perform_wrapper(receiver, selector, *args):
+ w_selector = None if isinstance(selector, str) else selector
+ return interp.perform(receiver, selector, w_selector, list(args))
+ perform = perform_wrapper
+ copy_to_module(locals(), __name__)
+
+def teardown_module():
+ cleanup_module(__name__)
+
+# ------ tests ------------------------------------------
+
+def test_compile_method():
+ sourcecode = """fib
+ ^self < 2
+ ifTrue: [ 1 ]
+ ifFalse: [ (self - 1) fib + (self - 2) fib ]"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ assert perform(w(10), "fib").is_same_object(w(89))
+
+def test_become():
+ sourcecode = """
+ testBecome
+ | p1 p2 a |
+ p1 := 1 at 2.
+ p2 := #(3 4 5).
+ a := p1 -> p2.
+ (1 at 2 = a key) ifFalse: [^1].
+ (#(3 4 5) = a value) ifFalse: [^2].
+ (p1 -> p2 = a) ifFalse: [^3].
+ (p1 == a key) ifFalse: [^4].
+ (p2 == a value) ifFalse: [^5].
+ p1 become: p2.
+ (1 at 2 = a value) ifFalse: [^6].
+ (3 = (a key at: 1)) ifFalse: [^7].
+ (4 = (a key at: 2)) ifFalse: [^8].
+ (5 = (a key at: 3)) ifFalse: [^9].
+ (p1 -> p2 = a) ifFalse: [^10].
+ (p1 == a key) ifFalse: [^11].
+ (p2 == a value) ifFalse: [^12].
+
+ ^42"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ w_result = perform(w(10), "testBecome")
+ assert space.unwrap_int(w_result) == 42
+
+def test_cached_methoddict():
+ sourcecode = """fib
+ ^self < 2
+ ifTrue: [ 1 ]
+ ifFalse: [ ((self - 1) fib + (self - 2) fib) + 1 ]"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ assert perform(w(5), "fib").is_same_object(w(15))
+ sourcecode = """fib
+ ^self < 2
+ ifTrue: [ 1 ]
+ ifFalse: [ (self - 1) fib + (self - 2) fib ]"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ assert perform(w(10), "fib").is_same_object(w(89))
+
+def test_compiling_float():
+ sourcecode = """aFloat
+ ^ 1.1"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ w_result = perform(w(10), "aFloat")
+ assert isinstance(w_result, model.W_Float)
+ assert w_result.value == 1.1
+
+def test_compiling_large_positive_integer():
+ sourcecode = """aLargeInteger
+ ^ 16rFFFFFFFF"""
+ perform(w(10).getclass(space), "compile:classified:notifying:", w(sourcecode), w('pypy'), w(None))
+ w_result = perform(w(10), "aLargeInteger")
+ assert isinstance(w_result, model.W_LargePositiveInteger1Word)
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -5,7 +5,7 @@
from rpython.rlib.rfloat import isinf, isnan
from rpython.rlib.rarithmetic import intmask
from rpython.rtyper.lltypesystem import lltype, rffi
-from .util import create_space, copy_to_module, cleanup_module, TestInterpreter
+from .util import create_space, copy_to_module, cleanup_module, TestInterpreter, slow_test
def setup_module():
space = create_space(bootstrap = True)
@@ -626,12 +626,14 @@
assert s_new_context.gettemp(1).as_string() == "second arg"
assert s_new_context.gettemp(2).as_string() == "some value"
+ at slow_test
def test_primitive_some_instance():
import gc; gc.collect()
someInstance = map(space.wrap_list, [[1], [2]])
w_r = prim(primitives.SOME_INSTANCE, [space.w_Array])
assert w_r.getclass(space) is space.w_Array
+ at slow_test
def test_primitive_next_instance():
someInstances = map(space.wrap_list, [[2], [3]])
w_frame, s_context = new_frame("<never called, but needed for method generation>")
@@ -648,6 +650,7 @@
assert w_2.getclass(space) is space.w_Array
assert w_1 is not w_2
+ at slow_test
def test_primitive_next_instance_wo_some_instance_in_same_frame():
someInstances = map(space.wrap_list, [[2], [3]])
w_frame, s_context = new_frame("<never called, but needed for method generation>")
@@ -702,12 +705,6 @@
monkeypatch.undo()
def test_primitive_be_display():
- # XXX: Patch SDLDisplay -> get_pixelbuffer() to circumvent
- # double-free bug
- def get_pixelbuffer(self):
- return lltype.malloc(rffi.ULONGP.TO, self.width * self.height * 32, flavor='raw')
- display.SDLDisplay.get_pixelbuffer = get_pixelbuffer
-
assert space.objtable["w_display"] is None
mock_display = model.W_PointersObject(space, space.w_Point, 4)
w_wordbmp = model.W_WordsObject(space, space.w_Array, 10)
@@ -741,12 +738,6 @@
assert mock_display.fetch(space, 0) is w_bitmap
def test_primitive_force_display_update(monkeypatch):
- # XXX: Patch SDLDisplay -> get_pixelbuffer() to circumvent
- # double-free bug
- def get_pixelbuffer(self):
- return lltype.malloc(rffi.ULONGP.TO, self.width * self.height * 32, flavor='raw')
- display.SDLDisplay.get_pixelbuffer = get_pixelbuffer
-
mock_display = model.W_PointersObject(space, space.w_Point, 4)
w_wordbmp = model.W_WordsObject(space, space.w_Array, 10)
mock_display.store(space, 0, w_wordbmp) # bitmap
diff --git a/spyvm/test/test_zin_squeak_4_5_image.py b/spyvm/test/test_zin_squeak_4_5_image.py
--- a/spyvm/test/test_zin_squeak_4_5_image.py
+++ b/spyvm/test/test_zin_squeak_4_5_image.py
@@ -1,7 +1,8 @@
+import operator
from spyvm import model
-from .util import read_image, copy_to_module, cleanup_module
+from .util import read_image, copy_to_module, cleanup_module, slow_test
-import operator
+pytestmark = slow_test
def setup_module():
space, interp, image, reader = read_image('Squeak4.5-12568.image')
diff --git a/spyvm/test/util.py b/spyvm/test/util.py
--- a/spyvm/test/util.py
+++ b/spyvm/test/util.py
@@ -2,6 +2,13 @@
from spyvm import model, storage_classes, objspace, util, constants, squeakimage, interpreter, interpreter_bytecodes
from rpython.rlib.objectmodel import instantiate
+# Use this as decorator, if the test takes longer then a few seconds.
+# This option is configured in conftest.py.
+# To mark all tests in a module as slow, add this line to the module:
+# pytestmark = slow_test
+slow_test = py.test.mark.skipif('not config.getvalue("execute-slow-tests")',
+ reason="Slow tests are being skipped. Add --slow to execute all tests.")
+
# Most tests don't need a bootstrapped objspace. Those that do, indicate so explicitely.
# This way, as many tests as possible use the real, not-bootstrapped ObjSpace.
bootstrap_by_default = False
@@ -17,10 +24,16 @@
def open_reader(space, imagefilename):
return squeakimage.ImageReader(space, image_stream(imagefilename))
-def read_image(image_filename, bootstrap = bootstrap_by_default):
- space = create_space(bootstrap)
- reader = open_reader(space, image_filename)
- image = reader.create_image()
+image_cache = {}
+
+def read_image(image_filename, cached=True):
+ if cached and image_filename in image_cache:
+ space, reader, image = image_cache.get(image_filename)
+ else:
+ space = create_space()
+ reader = open_reader(space, image_filename)
+ image = reader.create_image()
+ image_cache[image_filename] = (space, reader, image)
interp = TestInterpreter(space, image)
return space, interp, image, reader
@@ -35,7 +48,7 @@
interp = TestInterpreter(space)
return space, interp
-def copy_to_module(locals, module_name):
+def copy_to_module(locals, module_name, all_tests_slow = False):
mod = sys.modules[module_name]
mod._copied_objects_ = []
for name, obj in locals.items():
More information about the pypy-commit
mailing list