Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6688ef

Browse filesBrowse files
cjihrigtargos
authored andcommitted
test: use fs rimraf to refresh tmpdir
Now that the functionality is built into core, use it to refresh the test suite's tmpdir. PR-URL: #30569 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent fb2253e commit b6688ef
Copy full SHA for b6688ef

File tree

Expand file treeCollapse file tree

1 file changed

+1
-47
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-47
lines changed
Open diff view settings
Collapse file

‎test/common/tmpdir.js‎

Copy file name to clipboardExpand all lines: test/common/tmpdir.js
+1-47Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,53 +35,7 @@ function rimrafSync(pathname, { spawn = true } = {}) {
3535
}
3636
}
3737

38-
try {
39-
if (st.isDirectory())
40-
rmdirSync(pathname, null);
41-
else
42-
fs.unlinkSync(pathname);
43-
} catch (e) {
44-
debug(e);
45-
switch (e.code) {
46-
case 'ENOENT':
47-
// It's not there anymore. Work is done. Exiting.
48-
return;
49-
50-
case 'EPERM':
51-
// This can happen, try again with `rmdirSync`.
52-
break;
53-
54-
case 'EISDIR':
55-
// Got 'EISDIR' even after testing `st.isDirectory()`...
56-
// Try again with `rmdirSync`.
57-
break;
58-
59-
default:
60-
throw e;
61-
}
62-
rmdirSync(pathname, e);
63-
}
64-
}
65-
66-
function rmdirSync(p, originalEr) {
67-
try {
68-
fs.rmdirSync(p);
69-
} catch (e) {
70-
if (e.code === 'ENOTDIR')
71-
throw originalEr;
72-
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
73-
const enc = process.platform === 'linux' ? 'buffer' : 'utf8';
74-
fs.readdirSync(p, enc).forEach((f) => {
75-
if (f instanceof Buffer) {
76-
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
77-
rimrafSync(buf);
78-
} else {
79-
rimrafSync(path.join(p, f));
80-
}
81-
});
82-
fs.rmdirSync(p);
83-
}
84-
}
38+
fs.rmdirSync(pathname, { recursive: true, maxRetries: 5 });
8539
}
8640

8741
const testRoot = process.env.NODE_TEST_DIR ?

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.