[pypy-commit] pypy default: require a min. of Java 6, skip the jvm tests otherwise
pjenvey
noreply at buildbot.pypy.org
Sun Oct 21 02:52:11 CEST 2012
Author: Philip Jenvey <pjenvey at underboss.org>
Branch:
Changeset: r58293:16e5d86c8254
Date: 2012-10-20 17:49 -0700
http://bitbucket.org/pypy/pypy/changeset/16e5d86c8254/
Log: require a min. of Java 6, skip the jvm tests otherwise
diff --git a/pypy/doc/getting-started-dev.rst b/pypy/doc/getting-started-dev.rst
--- a/pypy/doc/getting-started-dev.rst
+++ b/pypy/doc/getting-started-dev.rst
@@ -100,7 +100,7 @@
To translate and run for the CLI you must have the SDK installed: Windows
users need the `.NET Framework SDK`_, while Linux and Mac users
can use Mono_. To translate and run for the JVM you must have a JDK
-installed (at least version 5) and ``java``/``javac`` on your path.
+installed (at least version 6) and ``java``/``javac`` on your path.
A slightly larger example
+++++++++++++++++++++++++
diff --git a/pypy/translator/jvm/genjvm.py b/pypy/translator/jvm/genjvm.py
--- a/pypy/translator/jvm/genjvm.py
+++ b/pypy/translator/jvm/genjvm.py
@@ -2,11 +2,12 @@
Backend for the JVM.
"""
+import os
+import re
+import subprocess
import sys
-import os
import py
-import subprocess
from pypy.tool.udir import udir
from pypy.translator.translator import TranslationContext
from pypy.translator.oosupport.genoo import GenOO
@@ -25,6 +26,8 @@
JVMWeakRefConst
from pypy.translator.jvm.prebuiltnodes import create_interlink_node
+MIN_JAVA_VERSION = '1.6.0'
+
class JvmError(Exception):
""" Indicates an error occurred in JVM backend """
@@ -222,12 +225,35 @@
jvm = GenJvm(tmpdir, t, EntryPoint(main_graph, True, True))
return jvm.generate_source()
+_missing_support_programs = None
+
def detect_missing_support_programs():
- def check(exechelper):
- if py.path.local.sysfind(exechelper) is None:
- py.test.skip("%s is not on your path" % exechelper)
- check(getoption('javac'))
- check(getoption('java'))
+ global _missing_support_programs
+ if _missing_support_programs is not None:
+ if _missing_support_programs:
+ py.test.skip(_missing_support_programs)
+ return
+
+ def missing(msg):
+ global _missing_support_programs
+ _missing_support_programs = msg
+ py.test.skip(msg)
+
+ for cmd in 'javac', 'java':
+ if py.path.local.sysfind(getoption(cmd)) is None:
+ missing("%s is not on your path" % cmd)
+ if not _check_java_version(MIN_JAVA_VERSION):
+ missing('Minimum of Java %s required' % MIN_JAVA_VERSION)
+ _missing_support_programs = False
+
+def _check_java_version(version):
+ """Determine if java meets the specified version"""
+ cmd = [getoption('java'), '-version']
+ with open(os.devnull, 'w') as devnull:
+ stderr = subprocess.Popen(cmd, stdout=devnull,
+ stderr=subprocess.PIPE).communicate()[1]
+ search = re.search('[\.0-9]+', stderr)
+ return search and search.group() >= version
class GenJvm(GenOO):
More information about the pypy-commit
mailing list