Commit 29a8e5dd authored by Gary Poster's avatar Gary Poster

Windows test fixes.

parent 35f81f2e
......@@ -32,12 +32,17 @@ if sys.platform == 'win32':
else:
quote = str
# Detect https://bugs.launchpad.net/virtualenv/+bug/572545 .
proc = subprocess.Popen(
[sys.executable, '-Sc', 'import ConfigParser'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.communicate()
has_broken_dash_S = bool(proc.returncode)
# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments.
stdout, stderr = subprocess.Popen(
[sys.executable, '-Sc',
'try:\n'
' import ConfigParser\n'
'except ImportError:\n'
' print 1\n'
'else:\n'
' print 0\n'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
has_broken_dash_S = bool(int(stdout.strip()))
# In order to be more robust in the face of system Pythons, we want to
# run without site-packages loaded. This is somewhat tricky, in
......
......@@ -122,7 +122,7 @@ except ImportError:
env = os.environ.copy() # Windows needs yet-to-be-determined values from this.
env['PYTHONPATH'] = os.path.dirname(pkg_resources.__file__)
cmd = [quote(sys.executable),
cmd = [sys.executable,
'setup.py', '-q', 'develop', '-m', '-x', '-d', 'develop-eggs']
if not has_broken_dash_S:
......
......@@ -85,11 +85,22 @@ if os.path.normpath(setuptools_loc) != os.path.normpath(buildout_loc):
def _has_broken_dash_S(executable):
"""Detect https://bugs.launchpad.net/virtualenv/+bug/572545 ."""
proc = subprocess.Popen(
[executable, '-Sc', 'import ConfigParser'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.communicate()
return bool(proc.returncode)
# The first attempt here was to simply have the executable attempt to import
# ConfigParser and return the return code. That worked except for tests on
# Windows, where the return code was wrong for the fake Python executable
# generated by the virtualenv.txt test, apparently because setuptools' .exe
# file does not pass the -script.py's returncode back properly, at least in
# some circumstances. Therefore...print statements.
stdout, stderr = subprocess.Popen(
[executable, '-Sc',
'try:\n'
' import ConfigParser\n'
'except ImportError:\n'
' print 1\n'
'else:\n'
' print 0\n'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
return bool(int(stdout.strip()))
def _get_system_paths(executable):
"""Return lists of standard lib and site paths for executable.
......
......@@ -4150,6 +4150,10 @@ def test_suite():
'setuptools.egg'),
(re.compile('zc.buildout-\S+-'),
'zc.buildout.egg'),
(re.compile(re.escape('#!"/executable_buildout/bin/py"')),
'#!/executable_buildout/bin/py'), # Windows.
(re.compile(re.escape('/broken_s/')),
'/broken_S/'), # Windows.
]),
))
......
......@@ -43,11 +43,17 @@ behavior as the problematic one we care about from virtualenv. Let's do that
first.
>>> import os, sys
>>> from zc.buildout.easy_install import _safe_arg
>>> py_path, site_packages_path = make_py()
>>> py_file = open(py_path)
>>> if sys.platform == 'win32':
... py_script_path = py_path + '-script.py'
... else:
... py_script_path = py_path
...
>>> py_file = open(py_script_path)
>>> py_lines = py_file.readlines()
>>> py_file.close()
>>> py_file = open(py_path, 'w')
>>> py_file = open(py_script_path, 'w')
>>> extra = '''\
... new_argv = argv[:1]
... for ix, val in enumerate(argv[1:]):
......@@ -109,11 +115,11 @@ first.
... ''' % (py_path,))
>>> sitecustomize_file.close()
>>> print call_py(
... py_path,
... _safe_arg(py_path),
... "import ConfigParser")
<BLANKLINE>
>>> print 'X'; print call_py(
... py_path,
... _safe_arg(py_path),
... "import ConfigParser",
... '-S') # doctest: +ELLIPSIS
X...Traceback (most recent call last):
......@@ -152,7 +158,7 @@ First, let's try running bootstrap.
... ''')
>>> write('bootstrap.py', open(bootstrap_py).read())
>>> print 'X'; print system(
... zc.buildout.easy_install._safe_arg(py_path)+' '+
... _safe_arg(py_path)+' '+
... 'bootstrap.py'); print 'X' # doctest: +ELLIPSIS
X...
Generated script '/broken_S/bin/buildout'.
......
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