[Checkins] SVN: zc.buildout/trunk/ A number of tests depended on being able to put scripts in a shebang

Jim Fulton jim at zope.com
Thu Mar 17 11:57:27 EDT 2011


Log message for revision 121009:
  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.
  

Changed:
  U   zc.buildout/trunk/src/zc/buildout/testing.py
  U   zc.buildout/trunk/src/zc/buildout/tests.py
  U   zc.buildout/trunk/z3c.recipe.scripts_/src/z3c/recipe/scripts/tests.py
  U   zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py

-=-
Modified: zc.buildout/trunk/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/testing.py	2011-03-17 15:57:23 UTC (rev 121008)
+++ zc.buildout/trunk/src/zc/buildout/testing.py	2011-03-17 15:57:26 UTC (rev 121009)
@@ -40,6 +40,18 @@
 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
 

Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py	2011-03-17 15:57:23 UTC (rev 121008)
+++ zc.buildout/trunk/src/zc/buildout/tests.py	2011-03-17 15:57:26 UTC (rev 121009)
@@ -29,7 +29,6 @@
 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 @@
     <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 @@
     <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,76 +2590,79 @@
 
     """
 
-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())
+if not zc.buildout.testing.script_in_shebang:
+    del bootstrap_makes_buildout_that_works_with_system_python
 
-        >>> call(buildout)
-        <BLANKLINE>
-        Exit: False
 
-        >>> write('buildout.cfg',
-        ... '''
-        ... [buildout]
-        ... parts = x
-        ... ''')
+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) # doctest: +NORMALIZE_WHITESPACE
-        While:
-          Installing.
-          Getting section x.
-        Error: The referenced section, 'x', was not defined.
-        <BLANKLINE>
-        Exit: True
+    >>> call(buildout)
+    <BLANKLINE>
+    Exit: False
 
-        >>> write('setup.py',
-        ... '''
-        ... from setuptools import setup
-        ... setup(name='zc.buildout.testexit', entry_points={
-        ...    'zc.buildout': ['default = testexitrecipe:x']})
-        ... ''')
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = x
+    ... ''')
 
-        >>> write('testexitrecipe.py',
-        ... '''
-        ... x y
-        ... ''')
+    >>> call(buildout) # doctest: +NORMALIZE_WHITESPACE
+    While:
+      Installing.
+      Getting section x.
+    Error: The referenced section, 'x', was not defined.
+    <BLANKLINE>
+    Exit: True
 
-        >>> write('buildout.cfg',
-        ... '''
-        ... [buildout]
-        ... parts = x
-        ... develop = .
-        ...
-        ... [x]
-        ... recipe = zc.buildout.testexit
-        ... ''')
+    >>> write('setup.py',
+    ... '''
+    ... from setuptools import setup
+    ... setup(name='zc.buildout.testexit', entry_points={
+    ...    'zc.buildout': ['default = testexitrecipe:x']})
+    ... ''')
 
-        >>> 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
-        """
+    >>> 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():
     """
     Recipes can rely on running from buildout directory
@@ -4093,7 +4102,6 @@
                 (re.compile('\-  demoneeded'), 'd  demoneeded'),
                 ]),
             ),
-        zc.buildout.testselectingpython.test_suite(),
         zc.buildout.rmtree.test_suite(),
         doctest.DocFileSuite(
             'windows.txt',
@@ -4138,6 +4146,10 @@
             ),
     ]
 
+
+    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(

Modified: zc.buildout/trunk/z3c.recipe.scripts_/src/z3c/recipe/scripts/tests.py
===================================================================
--- zc.buildout/trunk/z3c.recipe.scripts_/src/z3c/recipe/scripts/tests.py	2011-03-17 15:57:23 UTC (rev 121008)
+++ zc.buildout/trunk/z3c.recipe.scripts_/src/z3c/recipe/scripts/tests.py	2011-03-17 15:57:26 UTC (rev 121009)
@@ -69,6 +69,9 @@
     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 @@
 
 """
 
+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 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 @@
                 (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__':

Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py	2011-03-17 15:57:23 UTC (rev 121008)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py	2011-03-17 15:57:26 UTC (rev 121009)
@@ -138,9 +138,7 @@
             ),
         ))
 
-    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',



More information about the checkins mailing list