File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
5
5
## [ Unreleased]
6
6
7
+ ## Fixed
8
+
9
+ - Cap generated test ids to 255 characters to avoid file system errors ([ #35 ] ).
10
+
11
+ [ #35 ] : https://github.com/stackabletech/beku.py/pull/35
12
+
7
13
## 0.0.10 - 2024-11-06
8
14
9
15
## Added
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ def make_test_source_with_context(
96
96
97
97
98
98
def tid_short_hash (tid : str ) -> str :
99
+ """Take the first 10 chars of the hash of the given `tid`."""
99
100
return hashlib .sha256 (tid .encode ()).hexdigest ()[:10 ]
100
101
101
102
@@ -118,6 +119,9 @@ def tid(self) -> str:
118
119
"""Return the test id. Used as destination folder name for the generated test case.
119
120
The result is part of a full directory name of the test case. Therefore, the OS filesystem
120
121
directory separator is replaced with underscore.
122
+
123
+ Since the result is also used as a folder name, we restrict it's length to 255 characters.
124
+ This is because some filesystems complain if the name is longer that that.
121
125
"""
122
126
name = re .sub (
123
127
f"[{ os .sep } :]" ,
@@ -129,9 +133,10 @@ def tid(self) -> str:
129
133
)
130
134
),
131
135
)
132
- if len (name ) > 255 :
133
- hash = tid_short_hash (name )
134
- return f"{ name [:244 ]} _{ hash } "
136
+ max_len = 255
137
+ if len (name ) > max_len :
138
+ name_hash = tid_short_hash (name )
139
+ return f"{ name [: max_len - len (name_hash ) - 1 ]} _{ name_hash } "
135
140
else :
136
141
return name
137
142
You can’t perform that action at this time.
0 commit comments