[pypy-commit] pypy py3k: hg merge app_main-refactor again
antocuni
noreply at buildbot.pypy.org
Mon Jun 11 16:01:15 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r55581:22ff366ebf8a
Date: 2012-06-11 15:36 +0200
http://bitbucket.org/pypy/pypy/changeset/22ff366ebf8a/
Log: hg merge app_main-refactor again
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -290,6 +290,7 @@
return stream
def set_io_encoding(io_encoding, io_encoding_output, errors, overridden):
+ return # XXX fix this for py3k
try:
import _file
except ImportError:
@@ -741,14 +742,6 @@
if __name__ == '__main__':
- "For unit tests only"
- import autopath
- # we need to import pypy.translator.platform early, before we start to
- # mess up the env variables. In particular, during the import we spawn a
- # couple of processes which gets confused if PYTHONINSPECT is set (e.g.,
- # hg to get the version and the hack in tool.runsubprocess to prevent
- # out-of-memory for late os.fork())
- import pypy.translator.platform
# obscure! try removing the following line, see how it crashes, and
# guess why...
ImStillAroundDontForgetMe = sys.modules['__main__']
@@ -782,22 +775,22 @@
# debugging only
def pypy_find_executable(s):
- from pypy.module.sys.initpath import find_executable
- return find_executable(s)
+ import os
+ return os.path.abspath(s)
def pypy_find_stdlib(s):
- from pypy.module.sys.initpath import find_stdlib
- path, prefix = find_stdlib(None, s)
- if path is None:
- return None
- # contrarily to the interp-level version, we don't set sys.prefix
- # here, else CPythno stops to work (and e.g. test_proper_sys_path
- # fails)
- return path
+ from os.path import abspath, join, dirname as dn
+ thisfile = abspath(__file__)
+ root = dn(dn(dn(dn(thisfile))))
+ return [join(root, 'lib-python', '3.2'),
+ join(root, 'lib_pypy')]
def pypy_resolvedirof(s):
- from pypy.module.sys.initpath import resolvedirof
- return resolvedirof(s)
+ # we ignore the issue of symlinks; for tests, the executable is always
+ # translator/goal/app_main.py anyway
+ import os
+ return os.path.abspath(os.path.join(s, '..'))
+
# add an emulator for these pypy-only or 2.7-only functions
# (for test_pyc_commandline_argument)
diff --git a/pypy/translator/goal/test2/test_app_main.py b/pypy/translator/goal/test2/test_app_main.py
--- a/pypy/translator/goal/test2/test_app_main.py
+++ b/pypy/translator/goal/test2/test_app_main.py
@@ -216,6 +216,11 @@
http://pexpect.sourceforge.net/
"""
+ def setup_class(cls):
+ # some tests need to be able to import test2, change the cwd
+ goal_dir = os.path.abspath(os.path.join(autopath.this_dir, '..'))
+ os.chdir(goal_dir)
+
def _spawn(self, *args, **kwds):
try:
import pexpect
@@ -437,7 +442,7 @@
p = os.path.join(autopath.this_dir, 'mymodule.py')
p = os.path.abspath(p)
child = self.spawn(['-i',
- '-m', 'pypy.translator.goal.test2.mymodule',
+ '-m', 'test2.mymodule',
'extra'])
child.expect('mymodule running')
child.expect('Name: __main__')
@@ -448,9 +453,9 @@
child.expect(re.escape(repr("foobar")))
child.expect('>>> ')
child.sendline('import sys')
- child.sendline('"pypy.translator.goal.test2" in sys.modules')
+ child.sendline('"test2" in sys.modules')
child.expect('True')
- child.sendline('"pypy.translator.goal.test2.mymodule" in sys.modules')
+ child.sendline('"test2.mymodule" in sys.modules')
child.expect('False')
child.sendline('sys.path[0]')
child.expect("''")
@@ -541,7 +546,7 @@
child = self.spawn(['-cprint("hel" + "lo")'])
child.expect('hello')
- child = self.spawn(['-mpypy.translator.goal.test2.mymodule'])
+ child = self.spawn(['-mtest2.mymodule'])
child.expect('mymodule running')
def test_ps1_only_if_interactive(self):
@@ -646,7 +651,7 @@
skip("requires CPython >= 2.6")
p = os.path.join(autopath.this_dir, 'mymodule.py')
p = os.path.abspath(p)
- data = self.run('-m pypy.translator.goal.test2.mymodule extra')
+ data = self.run('-m test2.mymodule extra')
assert 'mymodule running' in data
assert 'Name: __main__' in data
# ignoring case for windows. abspath behaves different from autopath
More information about the pypy-commit
mailing list