Browse Source

Fix some tests on Mac OS X.

Jelmer Vernooij 4 years ago
parent
commit
8fe9680a10
3 changed files with 15 additions and 3 deletions
  1. 13 2
      dulwich/index.py
  2. 1 0
      dulwich/tests/test_hooks.py
  3. 1 1
      dulwich/tests/test_refs.py

+ 13 - 2
dulwich/index.py

@@ -560,8 +560,19 @@ def build_index_from_tree(root_path, index_path, object_store, tree_id,
             # TODO(jelmer): record and return submodule paths
         else:
             obj = object_store[entry.sha]
-            st = build_file_from_blob(
-                obj, entry.mode, full_path, honor_filemode=honor_filemode)
+            try:
+                st = build_file_from_blob(
+                    obj, entry.mode, full_path, honor_filemode=honor_filemode)
+            except OSError as e:
+                if e.errno == 92 and sys.platform == 'darwin':
+                    # Our filename isn't supported by the platform :(
+                    import warnings
+                    warnings.warn(
+                        'Unable to write ile %s: %s', full_path, e.strerror)
+                    continue
+                else:
+                    raise
+
         # Add file to index
         if not honor_filemode or S_ISGITLINK(entry.mode):
             # we can not use tuple slicing to build a new tuple,

+ 1 - 0
dulwich/tests/test_hooks.py

@@ -41,6 +41,7 @@ class ShellHookTests(TestCase):
         super(ShellHookTests, self).setUp()
         if os.name != 'posix':
             self.skipTest('shell hook tests requires POSIX shell')
+        self.assertTrue(os.path.exists('/bin/sh'))
 
     def test_hook_pre_commit(self):
         repo_dir = os.path.join(tempfile.mkdtemp())

+ 1 - 1
dulwich/tests/test_refs.py

@@ -572,7 +572,7 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         self.assertEqual(expected_refs, self._repo.get_refs())
 
     def test_cyrillic(self):
-        if sys.platform == 'win32':
+        if sys.platform in ('darwin', 'win32'):
             raise SkipTest(
                     "filesystem encoding doesn't support arbitrary bytes")
         # reported in https://github.com/dulwich/dulwich/issues/608