Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r88347:d9c685ecab5e
Date: 2016-11-13 15:53 +0100
http://bitbucket.org/pypy/pypy/changeset/d9c685ecab5e/

Log:    manual copy of dd2ec76131ce: require the --pypy option, instead of
        checking if we're run with "pypy py.test"

diff --git a/pypy/module/pypyjit/test_pypy_c/conftest.py 
b/pypy/module/pypyjit/test_pypy_c/conftest.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/conftest.py
@@ -0,0 +1,4 @@
+def pytest_addoption(parser):
+    group = parser.getgroup("pypyjit options")
+    group.addoption("--pypy", action="store", default=None, dest="pypy_c",
+                    help="the location of the JIT enabled pypy-c")
diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py 
b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -2,7 +2,7 @@
 import sys, os
 import types
 import subprocess
-import py
+import py, pytest
 from rpython.tool import disassembler
 from rpython.tool.udir import udir
 from rpython.tool import logparser
@@ -15,10 +15,20 @@
     log_string = 'jit-log-opt,jit-log-noopt,jit-log-virtualstate,jit-summary'
 
     def setup_class(cls):
-        if '__pypy__' not in sys.builtin_module_names:
-            py.test.skip("must run this test with pypy")
-        if not sys.pypy_translation_info['translation.jit']:
-            py.test.skip("must give a pypy-c with the jit enabled")
+        pypy_c = pytest.config.option.pypy_c or None
+        if pypy_c:
+            assert os.path.exists(pypy_c), (
+                "--pypy specifies %r, which does not exist" % (pypy_c,))
+            out = subprocess.check_output([pypy_c, '-c',
+            "import sys; print('__pypy__' in sys.builtin_module_names)"])
+            assert 'True' in out, "%r is not a pypy executable" % (pypy_c,)
+            out = subprocess.check_output([pypy_c, '-c',
+            "import sys; print(sys.pypy_translation_info['translation.jit'])"])
+            assert 'True' in out, "%r is a not a JIT-enabled pypy" % (pypy_c,)
+            out = subprocess.check_output([pypy_c, '-c',
+            "import sys; print(sys.version)"])
+            assert out.startswith('3'), "%r is a not a pypy 3" % (pypy_c,)
+        cls.pypy_c = pypy_c
         cls.tmpdir = udir.join('test-pypy-jit')
         cls.tmpdir.ensure(dir=True)
 
@@ -29,6 +39,8 @@
             discard_stdout_before_last_line=False, **jitopts):
         jitopts.setdefault('threshold', 200)
         jitopts.setdefault('disable_unrolling', 9999)
+        if self.pypy_c is None:
+            py.test.skip("run with --pypy=PATH")
         src = py.code.Source(func_or_src)
         if isinstance(func_or_src, types.FunctionType):
             funcname = func_or_src.func_name
@@ -42,12 +54,12 @@
             f.write("import sys\n")
             f.write("sys.setcheckinterval(10000000)\n")
             f.write(str(src) + "\n")
-            f.write("print %s(%s)\n" % (funcname, arglist))
+            f.write("print(%s(%s))\n" % (funcname, arglist))
         #
         # run a child pypy-c with logging enabled
         logfile = self.filepath.new(ext='.log')
         #
-        cmdline = [sys.executable]
+        cmdline = [self.pypy_c]
         if not import_site:
             cmdline.append('-S')
         if jitopts:
@@ -74,6 +86,9 @@
         #if stderr.startswith('debug_alloc.h:'):   # lldebug builds
         #    stderr = ''
         #assert not stderr
+        if not stdout:
+            raise Exception("no stdout produced; stderr='''\n%s'''"
+                            % (stderr,))
         if stderr:
             print '*** stderr of the subprocess: ***'
             print stderr
@@ -433,7 +448,7 @@
         import pytest
         def f():
             import sys
-            print >> sys.stderr, 'SKIP: foobar'
+            sys.stderr.write('SKIP: foobar\n')
         #
         raises(pytest.skip.Exception, "self.run(f, [])")
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to