File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 5
5
import logging
6
6
import os
7
7
import re
8
+ import hashlib
8
9
from dataclasses import dataclass , field
9
10
from functools import cached_property
10
11
from hashlib import sha256
@@ -94,6 +95,10 @@ def make_test_source_with_context(
94
95
return TestFile (file_name = file_name , source_dir = source_dir , dest_dir = dest_dir )
95
96
96
97
98
+ def tid_short_hash (tid : str ) -> str :
99
+ return hashlib .sha256 (tid .encode ()).hexdigest ()[:10 ]
100
+
101
+
97
102
@dataclass (frozen = True )
98
103
class TestCase :
99
104
"""A test case is an instance of test definition together with a set of Jinja variables used to render all
@@ -114,7 +119,7 @@ def tid(self) -> str:
114
119
The result is part of a full directory name of the test case. Therefore, the OS filesystem
115
120
directory separator is replaced with underscore.
116
121
"""
117
- return re .sub (
122
+ name = re .sub (
118
123
f"[{ os .sep } :]" ,
119
124
"_" ,
120
125
"_" .join (
@@ -124,6 +129,11 @@ def tid(self) -> str:
124
129
)
125
130
),
126
131
)
132
+ if len (name ) > 255 :
133
+ hash = tid_short_hash (name )
134
+ return f"{ name [:244 ]} _{ hash } "
135
+ else :
136
+ return name
127
137
128
138
def expand (self , template_dir : str , target_dir : str , namespace : str ) -> None :
129
139
"""Expand test case This will create the target folder, copy files and render render templates."""
You can’t perform that action at this time.
0 commit comments