Commit f0d0ef63 authored by jim's avatar jim

A number of tests depended on being able to put scripts in a shebang

line and thus failed on Mac OS X and other popular unix platforms.

Disabling these tests except on windows and new linux.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@121009 62d5b8a3-27da-0310-9561-8e5933582275
parent 5d5a2438
......@@ -40,6 +40,18 @@ from zc.buildout.rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None)
is_win32 = sys.platform == 'win32'
# Only some unixes allow scripts in shebang lines:
script_in_shebang = is_win32
if sys.platform == 'linux2':
f = subprocess.Popen('uname -r', shell=True, stdout=subprocess.PIPE).stdout
r = f.read().strip()
f.close()
r = tuple(map(int, re.match(r'\d+(\.\d+)*', r).group(0).split('.')))
if r >= (2, 6, 27, 9):
# http://www.in-ulm.de/~mascheck/various/shebang/
script_in_shebang = True
setuptools_location = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('setuptools')).location
......
......@@ -29,7 +29,6 @@ os_path_sep = os.path.sep
if os_path_sep == '\\':
os_path_sep *= 2
def develop_w_non_setuptools_setup_scripts():
"""
We should be able to deal with setup scripts that aren't setuptools based.
......@@ -1966,6 +1965,10 @@ results for the interpreter and for the script.
<BLANKLINE>
"""
if not zc.buildout.testing.script_in_shebang:
del handle_namespace_package_in_both_site_packages_and_buildout_eggs
def handle_sys_path_version_hack():
r"""
This is a test for a bugfix.
......@@ -2352,6 +2355,9 @@ site-packages are at the end. They were not before this bugfix.
<BLANKLINE>
"""
if not zc.buildout.testing.script_in_shebang:
del allowed_eggs_from_site_packages_bug_592524
def subprocesses_have_same_environment_by_default():
"""
The scripts generated by sitepackage_safe_scripts set the PYTHONPATH so that,
......@@ -2584,75 +2590,78 @@ Now we actually run the buildout.
"""
if sys.version_info > (2, 4):
def test_exit_codes():
"""
>>> import subprocess
>>> def call(s):
... p = subprocess.Popen(s, stdin=subprocess.PIPE,
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
... p.stdin.close()
... print p.stdout.read()
... print 'Exit:', bool(p.wait())
>>> call(buildout)
<BLANKLINE>
Exit: False
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = x
... ''')
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE
While:
Installing.
Getting section x.
Error: The referenced section, 'x', was not defined.
<BLANKLINE>
Exit: True
>>> write('setup.py',
... '''
... from setuptools import setup
... setup(name='zc.buildout.testexit', entry_points={
... 'zc.buildout': ['default = testexitrecipe:x']})
... ''')
>>> write('testexitrecipe.py',
... '''
... x y
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = x
... develop = .
...
... [x]
... recipe = zc.buildout.testexit
... ''')
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Develop: '/sample-buildout/.'
While:
Installing.
Getting section x.
Initializing section x.
Loading zc.buildout recipe entry zc.buildout.testexit:default.
<BLANKLINE>
An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
...
x y
^
SyntaxError: invalid syntax
<BLANKLINE>
Exit: True
"""
if not zc.buildout.testing.script_in_shebang:
del bootstrap_makes_buildout_that_works_with_system_python
def test_exit_codes():
"""
>>> import subprocess
>>> def call(s):
... p = subprocess.Popen(s, stdin=subprocess.PIPE,
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
... p.stdin.close()
... print p.stdout.read()
... print 'Exit:', bool(p.wait())
>>> call(buildout)
<BLANKLINE>
Exit: False
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = x
... ''')
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE
While:
Installing.
Getting section x.
Error: The referenced section, 'x', was not defined.
<BLANKLINE>
Exit: True
>>> write('setup.py',
... '''
... from setuptools import setup
... setup(name='zc.buildout.testexit', entry_points={
... 'zc.buildout': ['default = testexitrecipe:x']})
... ''')
>>> write('testexitrecipe.py',
... '''
... x y
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = x
... develop = .
...
... [x]
... recipe = zc.buildout.testexit
... ''')
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Develop: '/sample-buildout/.'
While:
Installing.
Getting section x.
Initializing section x.
Loading zc.buildout recipe entry zc.buildout.testexit:default.
<BLANKLINE>
An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
...
x y
^
SyntaxError: invalid syntax
<BLANKLINE>
Exit: True
"""
def bug_59270_recipes_always_start_in_buildout_dir():
"""
......@@ -4093,7 +4102,6 @@ def test_suite():
(re.compile('\- demoneeded'), 'd demoneeded'),
]),
),
zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite(
'windows.txt',
......@@ -4138,6 +4146,10 @@ def test_suite():
),
]
if zc.buildout.testing.script_in_shebang:
test_suite.append(zc.buildout.testselectingpython.test_suite())
# adding bootstrap.txt doctest to the suite
# only if bootstrap.py is present
bootstrap_py = os.path.join(
......
......@@ -69,6 +69,9 @@ some initialization that we can look for.
foo bar baz shazam
"""
if not zc.buildout.testing.script_in_shebang:
del supports_python_option
def interpreter_recipe_supports_extra_paths_option():
"""
This shows that specifying extra-paths will affect sys.path.
......@@ -195,6 +198,10 @@ custom Python.
"""
if not zc.buildout.testing.script_in_shebang:
del interpreter_recipe_supports_initialization_option
def interpreter_recipe_supports_relative_paths_option():
"""
This shows that the relative-paths option affects the code for inserting
......@@ -418,31 +425,6 @@ def setUpSelecting(test):
def test_suite():
suite = unittest.TestSuite((
doctest.DocFileSuite(
'README.txt',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.normalize_bang,
zc.buildout.tests.hide_distribute_additions,
zc.buildout.tests.hide_first_index_page_message,
(re.compile(r'zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'),
(re.compile('[-d] (setuptools|distribute)-[^-]+-'), 'setuptools-X-'),
(re.compile(r'(setuptools|distribute)-[\w.]+-py'), 'setuptools-X-py'),
(re.compile(r'eggs\\\\demo'), 'eggs/demo'),
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'),
(re.compile(r'\#!\S+\bpython\S*'), '#!/usr/bin/python'),
# Normalize generate_script's Windows interpreter to UNIX:
(re.compile(r'\nimport subprocess\n'), '\n'),
(re.compile('subprocess\\.call\\(argv, env=environ\\)'),
'os.execve(sys.executable, argv, environ)'),
(re.compile('distribute'), 'setuptools'),
])
),
doctest.DocTestSuite(
setUp=setUp,
tearDown=zc.buildout.testing.buildoutTearDown,
......@@ -455,9 +437,38 @@ def test_suite():
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'),
]),
),
))
if zc.buildout.testing.script_in_shebang:
suite.addTest(
doctest.DocFileSuite(
'README.txt',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.normalize_bang,
zc.buildout.tests.hide_distribute_additions,
zc.buildout.tests.hide_first_index_page_message,
(re.compile(r'zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'),
(re.compile('[-d] (setuptools|distribute)-[^-]+-'),
'setuptools-X-'),
(re.compile(r'(setuptools|distribute)-[\w.]+-py'),
'setuptools-X-py'),
(re.compile(r'eggs\\\\demo'), 'eggs/demo'),
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'),
(re.compile(r'\#!\S+\bpython\S*'), '#!/usr/bin/python'),
# Normalize generate_script's Windows interpreter to UNIX:
(re.compile(r'\nimport subprocess\n'), '\n'),
(re.compile('subprocess\\.call\\(argv, env=environ\\)'),
'os.execve(sys.executable, argv, environ)'),
(re.compile('distribute'), 'setuptools'),
])
))
return suite
if __name__ == '__main__':
......
......@@ -138,9 +138,7 @@ def test_suite():
),
))
if sys.version_info[:2] != (2, 4):
# Only run selecting python tests if not 2.4, since
# 2.4 is the alternate python used in the tests.
if zc.buildout.testing.script_in_shebang:
suite.addTest(
doctest.DocFileSuite(
'selecting-python.txt',
......
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