[pypy-svn] r79403 - in pypy/trunk/pypy/config: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Nov 23 16:03:06 CET 2010
Author: arigo
Date: Tue Nov 23 16:03:05 2010
New Revision: 79403
Modified:
pypy/trunk/pypy/config/support.py
pypy/trunk/pypy/config/test/test_support.py
Log:
Improve.
Modified: pypy/trunk/pypy/config/support.py
==============================================================================
--- pypy/trunk/pypy/config/support.py (original)
+++ pypy/trunk/pypy/config/support.py Tue Nov 23 16:03:05 2010
@@ -2,9 +2,13 @@
""" Some support code
"""
-import re
+import re, sys, os
def detect_number_of_processors(filename_or_file='/proc/cpuinfo'):
+ if sys.platform != 'linux2':
+ return 1 # implement me
+ if os.environ.get('MAKEFLAGS'):
+ return 1 # don't override MAKEFLAGS. This will call 'make' without any '-j' option
try:
if isinstance(filename_or_file, str):
f = open(filename_or_file, "r")
Modified: pypy/trunk/pypy/config/test/test_support.py
==============================================================================
--- pypy/trunk/pypy/config/test/test_support.py (original)
+++ pypy/trunk/pypy/config/test/test_support.py Tue Nov 23 16:03:05 2010
@@ -1,6 +1,7 @@
from cStringIO import StringIO
from pypy.config.support import detect_number_of_processors
+import os, sys, py
cpuinfo = """
processor : 0
@@ -31,6 +32,22 @@
siblings : 4
"""
+class FakeEnviron:
+ def __init__(self, value):
+ self._value = value
+ def get(self, varname):
+ assert varname == 'MAKEFLAGS'
+ return self._value
+
def test_cpuinfo():
- assert detect_number_of_processors(StringIO(cpuinfo)) == 4
- assert detect_number_of_processors('random crap that does not exist') == 1
+ if sys.platform != 'linux2':
+ py.test.skip("linux only")
+ saved = os.environ
+ try:
+ os.environ = FakeEnviron(None)
+ assert detect_number_of_processors(StringIO(cpuinfo)) == 4
+ assert detect_number_of_processors('random crap that does not exist') == 1
+ os.environ = FakeEnviron('-j2')
+ assert detect_number_of_processors(StringIO(cpuinfo)) == 1
+ finally:
+ os.environ = saved
More information about the Pypy-commit
mailing list