Commit 57e9e71d authored by jim's avatar jim

Added an uncd function to undo previous cd calls.

Changed a spawn call to a subprocess call to avoid some spurious output.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@122988 62d5b8a3-27da-0310-9561-8e5933582275
parent 754fc019
......@@ -147,14 +147,18 @@ def _runsetup(setup, executable, *args):
if executable == sys.executable:
env['PYTHONPATH'] = setuptools_location
# else pass an executable that has setuptools! See testselectingpython.py.
args.append(env)
here = os.getcwd()
try:
os.chdir(d)
os.spawnle(os.P_WAIT, executable,
zc.buildout.easy_install._safe_arg(executable),
setup, *args)
p = subprocess.Popen(
[zc.buildout.easy_install._safe_arg(executable), setup] + args,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
close_fds=True, env=env)
out = p.stdout.read()
if p.wait():
print out
if os.path.exists('build'):
rmtree('build')
finally:
......@@ -399,6 +403,15 @@ def buildoutSetUp(test):
return (
os.path.join(buildout, 'bin', 'py'), site_packages_dir)
cdpaths = []
def cd(*path):
path = os.path.join(*path)
cdpaths.append(os.path.abspath(os.getcwd()))
os.chdir(path)
def uncd():
os.chdir(cdpaths.pop())
test.globs.update(dict(
sample_buildout = sample,
ls = ls,
......@@ -411,7 +424,7 @@ def buildoutSetUp(test):
system = system,
call_py = call_py,
get = get,
cd = (lambda *path: os.chdir(os.path.join(*path))),
cd = cd, uncd = uncd,
join = os.path.join,
sdist = sdist,
bdist_egg = bdist_egg,
......
......@@ -79,6 +79,11 @@ number of names to the test namespace:
The directory will be reset at the end of the test.
``uncd()``
Change to the directory that was current prior to the previous
call to ``cd``. You can call ``cd`` multiple times and then
``uncd`` the same number of times to return to the same location.
``join(*path)``
A convenient reference to os.path.join.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment