Skip to content

Commit dfcca5c

Browse files
authored
restrict snapshot path for windows path length limit (vercel/turborepo#4639)
### Description windows...
1 parent 36434c8 commit dfcca5c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

crates/turbopack-test-utils/src/snapshot.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,22 @@ pub async fn snapshot_issues<
3131
let expected_issues = expected(issues_path).await?;
3232
let mut seen = HashSet::new();
3333
for (plain_issue, debug_string) in captured_issues.into_iter() {
34+
let title = plain_issue
35+
.title
36+
.replace('/', "__")
37+
// We replace "*", "?", and '"' because they're not allowed in filenames on Windows.
38+
.replace('*', "__star__")
39+
.replace('"', "__quo__")
40+
.replace('?', "__q__")
41+
.replace(':', "__c__");
42+
let title = if title.len() > 50 {
43+
&title[0..50]
44+
} else {
45+
&title
46+
};
3447
let hash = encode_hex(plain_issue.internal_hash(true));
3548

36-
let path = issues_path.join(&format!(
37-
"{}-{}.txt",
38-
plain_issue
39-
.title
40-
.replace('/', "__")
41-
// We replace "*", "?", and '"' because they're not allowed in filenames on Windows.
42-
.replace('*', "__star__")
43-
.replace('"', "__quo__")
44-
.replace('?', "__q__"),
45-
&hash[0..6]
46-
));
49+
let path = issues_path.join(&format!("{title}-{}.txt", &hash[0..6]));
4750
if !seen.insert(path) {
4851
continue;
4952
}

0 commit comments

Comments
 (0)