Use first 10 characters of sha256 in cache tests to shorten paths in test data

Otherwise, it affects developers on Windows, especially if they cannot increase
maximum path length limit on older versions of OS.

GitOrigin-RevId: 785363fcbb0d39f41b53211e2cef156cb672e525
This commit is contained in:
Mikhail Golubev
2019-06-10 22:09:16 +03:00
committed by intellij-monorepo-bot
parent 51fd4eca53
commit defc680bb1
34 changed files with 10 additions and 6 deletions
+6 -2
View File
@@ -364,9 +364,13 @@ def build_cache_dir_path(subdir, mod_qname, mod_path):
def module_hash(mod_qname, mod_path):
# Hash the content of a physical module
if mod_path:
return physical_module_hash(mod_path)
hash_ = physical_module_hash(mod_path)
else:
return builtin_module_hash(mod_qname)
hash_ = builtin_module_hash(mod_qname)
# Use shorter hashes in test data as it might affect developers on Windows
if is_test_mode():
return hash_[:10]
return hash_
def builtin_module_hash(mod_qname):
@@ -125,11 +125,11 @@ class SkeletonCachingTest(GeneratorTestCase):
_ast.py
sdk_skeletons/
_ast.py
""".format(hash=generator3.builtin_module_hash('_ast')))
""".format(hash=generator3.builtin_module_hash('_ast')[:10]))
def test_builtins_generation_mode_stores_all_skeletons_in_same_cache_directory(self):
self.run_generator(builtins=True)
builtins_hash = generator3.builtin_module_hash('sys')
builtins_hash = generator3.builtin_module_hash('sys')[:10]
builtins_cache_dir = os.path.join(self.temp_cache_dir, builtins_hash)
self.assertTrue(os.path.isdir(builtins_cache_dir))
builtin_mod_skeletons = os.listdir(builtins_cache_dir)
@@ -145,7 +145,7 @@ class SkeletonCachingTest(GeneratorTestCase):
mod.py
sdk_skeletons/
mod.py
""".format(hash=generator3.physical_module_hash(mod_path)))
""".format(hash=generator3.physical_module_hash(mod_path)[:10]))
def test_layout_for_physical_module_inside_package(self):
mod_path = self.get_test_data_path('pkg/subpkg/mod.py')
@@ -164,7 +164,7 @@ class SkeletonCachingTest(GeneratorTestCase):
subpkg/
__init__.py
mod.py
""".format(hash=generator3.physical_module_hash(mod_path)))
""".format(hash=generator3.physical_module_hash(mod_path)[:10]))
def test_skeleton_regenerated_for_changed_module(self):
self.check_generator_output('mod', mod_path='mod.py', mod_root='versions/v2')