refine rsyncing and internal dir/transferal handling: don't transfer roots in a popen- no-chdir situation and only use one py._pydir everywhere

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-01-11 14:30:50 +01:00
parent 352e305431
commit ba1451330e
15 changed files with 36 additions and 35 deletions

View File

@ -50,6 +50,8 @@ Changes between 1.X and 1.1.1
- change: pytest doctest plugin is now enabled by default and has a
new option --doctest-glob to set a pattern for file matches.
- change: remove internal py._* helper vars, only keep py._pydir
- robustify capturing to survive if custom pytest_runtest_setup
code failed and prevented the capturing setup code from running.

View File

@ -128,7 +128,7 @@ class RestWriter:
class PluginOverview(RestWriter):
def makerest(self, config):
plugindir = py._dir.join('plugin')
plugindir = py._pydir.join('plugin')
for cat, specs in plugins:
pluginlist = specs.split()
self.h1(cat)

View File

@ -19,9 +19,7 @@ py.apipkg.initpkg(__name__, dict(
# access to all posix errno's as classes
error = '.impl.error:error',
_impldir = '.impl._metainfo:impldir',
_dir = '.impl._metainfo:pydir',
_pydirs = '.impl._metainfo:pydirs',
_pydir = '.impl._metainfo:pydir',
version = 'py:__version__', # backward compatibility
cmdline = {

View File

@ -1,9 +1,2 @@
import py
pydir = py.path.local(py.__file__).dirpath()
impldir = pydir.join("impl")
# list of all directories beloging to py
assert impldir.relto(pydir)
pydirs = [pydir]

View File

@ -257,7 +257,7 @@ class Collector(Node):
path = self.fspath
ntraceback = traceback.cut(path=self.fspath)
if ntraceback == traceback:
ntraceback = ntraceback.cut(excludepath=py._dir)
ntraceback = ntraceback.cut(excludepath=py._pydir)
traceback = ntraceback.filter()
return traceback

View File

@ -269,21 +269,17 @@ class Config(object):
def getrsyncdirs(self):
config = self
roots = config.option.rsyncdir
candidates = [py._pydir] + config.option.rsyncdir
conftestroots = config.getconftest_pathlist("rsyncdirs")
if conftestroots:
roots.extend(conftestroots)
pydirs = [x.realpath() for x in py._pydirs]
roots = [py.path.local(root) for root in roots]
for root in roots:
candidates.extend(conftestroots)
roots = []
for root in candidates:
root = py.path.local(root).realpath()
if not root.check():
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
if pydirs is not None and root.basename in ("py", "_py"):
try:
pydirs.remove(root) # otherwise it's a conflict
except ValueError: # we run as standalone py.test
pass
roots.extend(pydirs)
if root not in roots:
roots.append(root)
return roots
#

View File

@ -3,7 +3,7 @@
"""
import py
import sys, os
import sys, os.path
import execnet
from execnet.gateway_base import RemoteError
@ -35,7 +35,12 @@ class GatewayManager:
gateways = []
for gateway in self.group:
spec = gateway.spec
if spec.popen and not spec.chdir and not spec.python:
if spec.popen and not spec.chdir:
# XXX this assumes that sources are python-packages
# and that adding the basedir does not hurt
gateway.remote_exec("""
import sys ; sys.path.insert(0, %r)
""" % os.path.dirname(str(source))).waitclose()
continue
if spec not in seen:
def finished():

View File

@ -246,7 +246,7 @@ class FunctionMixin(PyobjMixin):
if ntraceback == traceback:
ntraceback = ntraceback.cut(path=path)
if ntraceback == traceback:
ntraceback = ntraceback.cut(excludepath=py._dir)
ntraceback = ntraceback.cut(excludepath=py._pydir)
traceback = ntraceback.filter()
return traceback

View File

@ -318,7 +318,7 @@ class TmpTestdir:
assert hasattr(py.cmdline, cmdlinename), cmdlinename
source = ("import sys ; sys.path.insert(0, %r); "
"import py ; py.cmdline.%s()" %
(str(py._dir.dirpath()), cmdlinename))
(str(py._pydir.dirpath()), cmdlinename))
return (sys.executable, "-c", source,)
def runpython(self, script):
@ -329,7 +329,7 @@ class TmpTestdir:
def _getsysprepend(self):
if not self.request.config.getvalue("toolsonpath"):
s = "import sys ; sys.path.insert(0, %r) ; " % str(py._dir.dirpath())
s = "import sys ; sys.path.insert(0, %r) ; " % str(py._pydir.dirpath())
else:
s = ""
return s

View File

@ -174,7 +174,7 @@ class ReSTSyntaxTest(py.test.collect.Item):
'to the py package') % (text,)
relpath = '/'.join(text.split('/')[1:])
if check:
pkgroot = py._impldir
pkgroot = py._pydir
abspath = pkgroot.join(relpath)
assert pkgroot.join(relpath).check(), (
'problem with linkrole :source:`%s`: '

View File

@ -112,7 +112,7 @@ class TestTraceback_f_g_h:
def test_traceback_cut_excludepath(self, testdir):
p = testdir.makepyfile("def f(): raise ValueError")
excinfo = py.test.raises(ValueError, "p.pyimport().f()")
basedir = py._impldir
basedir = py._pydir
newtraceback = excinfo.traceback.cut(excludepath=basedir)
assert len(newtraceback) == 1
assert newtraceback[0].frame.code.path == p

View File

@ -59,7 +59,7 @@ class TestDistOptions:
def test_getrsyncdirs(self, testdir):
config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
roots = config.getrsyncdirs()
assert len(roots) == 1 + len(py._pydirs)
assert len(roots) == 1 + 1 # pylib itself
assert testdir.tmpdir in roots
def test_getrsyncdirs_with_conftest(self, testdir):
@ -71,7 +71,7 @@ class TestDistOptions:
""")
config = testdir.parseconfigure(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
roots = config.getrsyncdirs()
assert len(roots) == 3 + len(py._pydirs)
assert len(roots) == 3 + 1 # pylib itself
assert py.path.local('y') in roots
assert py.path.local('z') in roots
assert testdir.tmpdir.join('x') in roots

View File

@ -51,12 +51,19 @@ class TestGatewayManagerPopen:
hm.makegateways()
assert len(hm.group) == 2
for gw in hm.group:
gw.remote_exec = None
class pseudoexec:
args = []
def __init__(self, *args):
self.args.extend(args)
def waitclose(self):
pass
gw.remote_exec = pseudoexec
l = []
hm.rsync(source, notify=lambda *args: l.append(args))
assert not l
hm.exit()
assert not len(hm.group)
assert "sys.path.insert" in gw.remote_exec.args[0]
def test_rsync_popen_with_path(self, hook, mysetup):
source, dest = mysetup.source, mysetup.dest

View File

@ -66,6 +66,6 @@ def test_pytest_cmdline_main(testdir):
assert 1
if __name__ == '__main__':
py.test.cmdline.main([__file__])
""" % (str(py._dir.dirpath())))
""" % (str(py._pydir.dirpath())))
import subprocess
subprocess.check_call([sys.executable, str(p)])

View File

@ -25,7 +25,7 @@ def test_virtual_module_identity():
assert local1 is local2
def test_importall():
base = py._impldir
base = py._pydir.join("impl")
nodirs = [
base.join('test', 'testing', 'data'),
base.join('path', 'gateway',),