Commits

Ronald Oussoren  committed a911ab0

- Don't rebuild the stub executables automaticly, that's
unsafe with Xcode 4 and could trigger accidently when
files are installed in a different order than expected.

- Small tweaks to the testsuite to ensure that they work
on systems with both Xcode3 and Xcode4 (Xcode3 must be
the selected version).

- Better cleanup in the testsuite when ``setupClass`` fails.

  • Participants
  • Parent commits f786eb2

Comments (0)

Files changed (7)

File doc/changelog.rst

   stub executables, in particular not those that have support
   for the PPC architecture.
 
+- Don't rebuild the stub executables automaticly, that's 
+  unsafe with Xcode 4 and could trigger accidently when
+  files are installed in a different order than expected.
+
+- Small tweaks to the testsuite to ensure that they work
+  on systems with both Xcode3 and Xcode4 (Xcode3 must be
+  the selected version).
+
+- Better cleanup in the testsuite when ``setupClass`` fails.
+
 py2app 0.6
 ----------
 

File py2app/apptemplate/setup.py

     root = None
 
 
-    for entry in gPreBuildVariants:
-        if (not all) and entry['name'] != name: continue
+    if all:
+        for entry in gPreBuildVariants:
+            if (not all) and entry['name'] != name: continue
 
-        dest = os.path.join(builddir, entry['name'])
+            dest = os.path.join(builddir, entry['name'])
 
-        if not os.path.exists(dest) or (
-                os.stat(dest).st_mtime < os.stat(src).st_mtime):
-            if root is None:
-                fp = os.popen('xcode-select -print-path', 'r')
-                root = fp.read().strip()
-                fp.close()
+            if not os.path.exists(dest) or (
+                    os.stat(dest).st_mtime < os.stat(src).st_mtime):
+                if root is None:
+                    fp = os.popen('xcode-select -print-path', 'r')
+                    root = fp.read().strip()
+                    fp.close()
 
-            CC=os.path.join(root, 'usr', 'bin', entry['cc'])
-            CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
-            os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
-            os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s' % locals())
+                CC=os.path.join(root, 'usr', 'bin', entry['cc'])
+                CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
+                os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
+                os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s' % locals())
 
     dest = os.path.join(
             builddir,

File py2app/bundletemplate/setup.py

     root = None
 
 
-    for entry in gPreBuildVariants:
-        if (not all) and entry['name'] != name: continue
+    if all:
+        for entry in gPreBuildVariants:
+            if (not all) and entry['name'] != name: continue
 
-        dest = os.path.join(builddir, entry['name'])
-        if not os.path.exists(dest) or (
-                os.stat(dest).st_mtime < os.stat(src).st_mtime):
-            if root is None:
-                fp = os.popen('xcode-select -print-path', 'r')
-                root = fp.read().strip()
-                fp.close()
+            dest = os.path.join(builddir, entry['name'])
+            if not os.path.exists(dest) or (
+                    os.stat(dest).st_mtime < os.stat(src).st_mtime):
+                if root is None:
+                    fp = os.popen('xcode-select -print-path', 'r')
+                    root = fp.read().strip()
+                    fp.close()
 
-            CC=os.path.join(root, 'usr', 'bin', entry['cc'])
-            CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
-            os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
-            os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s' % locals())
+                CC=os.path.join(root, 'usr', 'bin', entry['cc'])
+                CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
+                os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
+                os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s' % locals())
 
     dest = os.path.join(
             builddir,

File py2app_tests/test_basic_app.py

 
     @classmethod
     def setUpClass(cls):
-        if os.path.exists(cls.app_dir):
-            shutil.rmtree(cls.app_dir)
+        try:
+            if os.path.exists(cls.app_dir):
+                shutil.rmtree(cls.app_dir)
 
-        assert not os.path.exists(cls.app_dir)
-        shutil.copytree(TestBasicApp.app_dir, cls.app_dir)
+            assert not os.path.exists(cls.app_dir)
+            shutil.copytree(TestBasicApp.app_dir, cls.app_dir)
 
-        super(TestBasicAppUnicodePath, cls).setUpClass()
+            super(TestBasicAppUnicodePath, cls).setUpClass()
+
+        except:
+            if os.path.exists(cls.app_dir):
+                shutil.rmtree(cls.app_dir)
+
+            raise
 
     @classmethod
     def tearDownClass(cls):

File py2app_tests/test_basic_plugin.py

     # a base-class.
     @classmethod
     def setUpClass(cls):
-        cmd = [ sys.executable, 'setup.py', 'py2app'] + cls.py2app_args
-        
-        p = subprocess.Popen(
-            cmd,
-            cwd = cls.plugin_dir,
-            stdout=subprocess.PIPE,
-            stderr=subprocess.STDOUT,
-            close_fds=True)
-        lines = p.communicate()[0]
-        if p.wait() != 0:
-            print (lines)
-            raise AssertionError("Creating basic_plugin bundle failed")
+        try:
+            if os.path.exists(os.path.join(cls.plugin_dir, 'build')):
+                shutil.rmtree(os.path.join(cls.plugin_dir, 'build'))
 
-        p = subprocess.Popen([
-            'gcc'] +  get_config_var('LDFLAGS').split() + [ 
-                '-o', 'bundle_loader', os.path.join(DIR_NAME, 'bundle_loader.m'), 
-                '-framework', 'Foundation'],
-            stdout=subprocess.PIPE,
-            stderr=subprocess.STDOUT,
-            close_fds=True)
-        lines = p.communicate()[0]
-        if p.wait() != 0:
-            print (lines)
-            raise AssertionError("Creating bundle_loader failed")
+            if os.path.exists(os.path.join(cls.plugin_dir, 'dist')):
+                shutil.rmtree(os.path.join(cls.plugin_dir, 'dist'))
+
+            cmd = [ sys.executable, 'setup.py', 'py2app'] + cls.py2app_args
+            
+            p = subprocess.Popen(
+                cmd,
+                cwd = cls.plugin_dir,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.STDOUT,
+                close_fds=True)
+            lines = p.communicate()[0]
+            if p.wait() != 0:
+                print (lines)
+                raise AssertionError("Creating basic_plugin bundle failed")
+
+            p = subprocess.Popen([
+                'xcode-select', '-print-path'
+            ], stdout = subprocess.PIPE)
+            lines = p.communicate()[0]
+            xit = p.wait()
+            if p.wait() != 0:
+                raise AssertionError("Fetching Xcode root failed")
+
+            root = lines.strip()
+            if sys.version_info[0] != 2:
+                root = root.decode('utf-8')
+
+            cc = get_config_var('CC')
+
+            p = subprocess.Popen([os.path.join(root, 'usr', 'bin', cc) ] 
+                +  get_config_var('LDFLAGS').split() + [ 
+                    '-o', 'bundle_loader', os.path.join(DIR_NAME, 'bundle_loader.m'), 
+                    '-framework', 'Foundation'],
+                stdout=subprocess.PIPE,
+                stderr=subprocess.STDOUT,
+                close_fds=True)
+            lines = p.communicate()[0]
+            if p.wait() != 0:
+                print (lines)
+                raise AssertionError("Creating bundle_loader failed")
+
+
+        except:
+            cls.tearDownClass()
+            raise
 
     @classmethod
     def tearDownClass(cls):
 
     def test_basic_start(self):
         p = self.start_app()
-        p.stdout.readline()
+        v = p.stdout.readline()
+
+        self.assertFalse(v.startswith(B('** Cannot load bundle')))
 
         p.stdin.write('BasicPlugin.bundle:test startup\n'.encode('latin1'))
         p.stdin.flush()
 
     @classmethod
     def setUpClass(cls):
-        if os.path.exists(cls.plugin_dir):
-            shutil.rmtree(cls.plugin_dir)
+        try:
+            if os.path.exists(cls.plugin_dir):
+                shutil.rmtree(cls.plugin_dir)
 
-        assert not os.path.exists(cls.plugin_dir)
-        shutil.copytree(TestBasicPlugin.plugin_dir, cls.plugin_dir)
+            assert not os.path.exists(cls.plugin_dir)
+            shutil.copytree(TestBasicPlugin.plugin_dir, cls.plugin_dir)
 
-        super(TestBasicPluginUnicodePath, cls).setUpClass()
+            super(TestBasicPluginUnicodePath, cls).setUpClass()
+
+        except:
+            if os.path.exists(cls.plugin_dir):
+                shutil.rmtree(cls.plugin_dir)
+            raise
 
     @classmethod
     def tearDownClass(cls):

File py2app_tests/test_py2applet.py

     def run_py2applet(self, *args):
         scriptfn = script_py2applet.__file__
         if scriptfn.endswith('.pyc'):
-            scriptfn = fn[:-1]
+            scriptfn = scriptfn[:-1]
             
         p = subprocess.Popen([
             sys.executable, scriptfn ] + list(args),
 
 
 def test_loader():
+
     if sys.version_info[0] == 3 or sys.version_info[:2] >= (2, 7):
         import unittest
     else: