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 ...@@ -40,6 +40,18 @@ from zc.buildout.rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None) fsync = getattr(os, 'fsync', lambda fileno: None)
is_win32 = sys.platform == 'win32' 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( setuptools_location = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('setuptools')).location pkg_resources.Requirement.parse('setuptools')).location
......
...@@ -29,7 +29,6 @@ os_path_sep = os.path.sep ...@@ -29,7 +29,6 @@ os_path_sep = os.path.sep
if os_path_sep == '\\': if os_path_sep == '\\':
os_path_sep *= 2 os_path_sep *= 2
def develop_w_non_setuptools_setup_scripts(): def develop_w_non_setuptools_setup_scripts():
""" """
We should be able to deal with setup scripts that aren't setuptools based. 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. ...@@ -1966,6 +1965,10 @@ results for the interpreter and for the script.
<BLANKLINE> <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(): def handle_sys_path_version_hack():
r""" r"""
This is a test for a bugfix. This is a test for a bugfix.
...@@ -2352,6 +2355,9 @@ site-packages are at the end. They were not before this bugfix. ...@@ -2352,6 +2355,9 @@ site-packages are at the end. They were not before this bugfix.
<BLANKLINE> <BLANKLINE>
""" """
if not zc.buildout.testing.script_in_shebang:
del allowed_eggs_from_site_packages_bug_592524
def subprocesses_have_same_environment_by_default(): def subprocesses_have_same_environment_by_default():
""" """
The scripts generated by sitepackage_safe_scripts set the PYTHONPATH so that, The scripts generated by sitepackage_safe_scripts set the PYTHONPATH so that,
...@@ -2584,75 +2590,78 @@ Now we actually run the buildout. ...@@ -2584,75 +2590,78 @@ Now we actually run the buildout.
""" """
if sys.version_info > (2, 4): if not zc.buildout.testing.script_in_shebang:
def test_exit_codes(): del bootstrap_makes_buildout_that_works_with_system_python
"""
>>> import subprocess
>>> def call(s): def test_exit_codes():
... p = subprocess.Popen(s, stdin=subprocess.PIPE, """
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >>> import subprocess
... p.stdin.close() >>> def call(s):
... print p.stdout.read() ... p = subprocess.Popen(s, stdin=subprocess.PIPE,
... print 'Exit:', bool(p.wait()) ... stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
... p.stdin.close()
>>> call(buildout) ... print p.stdout.read()
<BLANKLINE> ... print 'Exit:', bool(p.wait())
Exit: False
>>> call(buildout)
>>> write('buildout.cfg', <BLANKLINE>
... ''' Exit: False
... [buildout]
... parts = x >>> write('buildout.cfg',
... ''') ... '''
... [buildout]
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE ... parts = x
While: ... ''')
Installing.
Getting section x. >>> call(buildout) # doctest: +NORMALIZE_WHITESPACE
Error: The referenced section, 'x', was not defined. While:
<BLANKLINE> Installing.
Exit: True Getting section x.
Error: The referenced section, 'x', was not defined.
>>> write('setup.py', <BLANKLINE>
... ''' Exit: True
... from setuptools import setup
... setup(name='zc.buildout.testexit', entry_points={ >>> write('setup.py',
... 'zc.buildout': ['default = testexitrecipe:x']}) ... '''
... ''') ... from setuptools import setup
... setup(name='zc.buildout.testexit', entry_points={
>>> write('testexitrecipe.py', ... 'zc.buildout': ['default = testexitrecipe:x']})
... ''' ... ''')
... x y
... ''') >>> write('testexitrecipe.py',
... '''
>>> write('buildout.cfg', ... x y
... ''' ... ''')
... [buildout]
... parts = x >>> write('buildout.cfg',
... develop = . ... '''
... ... [buildout]
... [x] ... parts = x
... recipe = zc.buildout.testexit ... develop = .
... ''') ...
... [x]
>>> call(buildout) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS ... recipe = zc.buildout.testexit
Develop: '/sample-buildout/.' ... ''')
While:
Installing. >>> call(buildout) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Getting section x. Develop: '/sample-buildout/.'
Initializing section x. While:
Loading zc.buildout recipe entry zc.buildout.testexit:default. Installing.
<BLANKLINE> Getting section x.
An internal error occurred due to a bug in either zc.buildout or in a Initializing section x.
recipe being used: Loading zc.buildout recipe entry zc.buildout.testexit:default.
Traceback (most recent call last): <BLANKLINE>
... An internal error occurred due to a bug in either zc.buildout or in a
x y recipe being used:
^ Traceback (most recent call last):
SyntaxError: invalid syntax ...
<BLANKLINE> x y
Exit: True ^
""" SyntaxError: invalid syntax
<BLANKLINE>
Exit: True
"""
def bug_59270_recipes_always_start_in_buildout_dir(): def bug_59270_recipes_always_start_in_buildout_dir():
""" """
...@@ -4093,7 +4102,6 @@ def test_suite(): ...@@ -4093,7 +4102,6 @@ def test_suite():
(re.compile('\- demoneeded'), 'd demoneeded'), (re.compile('\- demoneeded'), 'd demoneeded'),
]), ]),
), ),
zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(), zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite( doctest.DocFileSuite(
'windows.txt', 'windows.txt',
...@@ -4138,6 +4146,10 @@ def test_suite(): ...@@ -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 # adding bootstrap.txt doctest to the suite
# only if bootstrap.py is present # only if bootstrap.py is present
bootstrap_py = os.path.join( bootstrap_py = os.path.join(
......
...@@ -69,6 +69,9 @@ some initialization that we can look for. ...@@ -69,6 +69,9 @@ some initialization that we can look for.
foo bar baz shazam foo bar baz shazam
""" """
if not zc.buildout.testing.script_in_shebang:
del supports_python_option
def interpreter_recipe_supports_extra_paths_option(): def interpreter_recipe_supports_extra_paths_option():
""" """
This shows that specifying extra-paths will affect sys.path. This shows that specifying extra-paths will affect sys.path.
...@@ -195,6 +198,10 @@ custom Python. ...@@ -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(): def interpreter_recipe_supports_relative_paths_option():
""" """
This shows that the relative-paths option affects the code for inserting This shows that the relative-paths option affects the code for inserting
...@@ -418,31 +425,6 @@ def setUpSelecting(test): ...@@ -418,31 +425,6 @@ def setUpSelecting(test):
def test_suite(): def test_suite():
suite = unittest.TestSuite(( 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( doctest.DocTestSuite(
setUp=setUp, setUp=setUp,
tearDown=zc.buildout.testing.buildoutTearDown, tearDown=zc.buildout.testing.buildoutTearDown,
...@@ -455,9 +437,38 @@ def test_suite(): ...@@ -455,9 +437,38 @@ def test_suite():
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'), (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 return suite
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -138,9 +138,7 @@ def test_suite(): ...@@ -138,9 +138,7 @@ def test_suite():
), ),
)) ))
if sys.version_info[:2] != (2, 4): if zc.buildout.testing.script_in_shebang:
# Only run selecting python tests if not 2.4, since
# 2.4 is the alternate python used in the tests.
suite.addTest( suite.addTest(
doctest.DocFileSuite( doctest.DocFileSuite(
'selecting-python.txt', '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