test(fs): check ensureDir() is not racy (#5086)

This commit is contained in:
Yoshiya Hinosawa 2024-06-19 19:12:54 +09:00 committed by GitHub
parent 41a2da4788
commit ec27c49cbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -187,3 +187,22 @@ Deno.test({
);
},
});
Deno.test({
name: "ensureDir() isn't racy",
async fn() {
for (const _ of Array(100)) {
const dir = path.join(
await Deno.makeTempDir(),
"check",
"race",
);
// It doesn't throw with successive calls.
await Promise.all([
ensureDir(dir),
ensureDir(dir),
]);
}
},
});