Skip to content

Commit 4bf372d

Browse files
committed
test_submodule: Will now load everything into memory if smmap is present, to help the submodule test to work even on windows
1 parent e00bf79 commit 4bf372d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

git/test/objects/test_submodule.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@
99

1010
import shutil
1111
import git
12+
import sys
1213
import os
1314
import sys
1415

16+
# Change the configuration if possible to prevent the underlying memory manager
17+
# to keep file handles open. On windows we get problems as they are not properly
18+
# closed due to mmap bugs on windows (as it appears)
19+
if sys.platform == 'win32':
20+
try:
21+
import smmap.util
22+
smmap.util.MapRegion._test_read_into_memory = True
23+
except ImportError:
24+
sys.stderr.write("The submodule tests will fail as some files cannot be removed due to open file handles.\n")
25+
sys.stderr.write("The latest version of gitdb uses a memory map manager which can be configured to work around this problem")
26+
#END handle windows platform
27+
28+
1529
class TestRootProgress(RootUpdateProgress):
1630
"""Just prints messages, for now without checking the correctness of the states"""
1731

0 commit comments

Comments
 (0)