Skip to content

Commit 9e7cfbb

Browse files
bcoedanielleadams
authored andcommitted
test: add missing await in fs-rm/fs-rmdir tests
Noticed that a few assertions were not being awaited, this could potentially be leading to flakiness in tmp cleanup. Refs: #41201 PR-URL: #41545 Refs: #41201 Reviewed-By: Ian Sutherland <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 82042d0 commit 9e7cfbb

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/parallel/test-fs-rm.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,19 @@ function removeAsync(dir) {
184184
makeNonEmptyDirectory(4, 10, 2, dir, true);
185185

186186
// Removal should fail without the recursive option set to true.
187-
assert.rejects(fs.promises.rm(dir), { syscall: 'rm' });
188-
assert.rejects(fs.promises.rm(dir, { recursive: false }), {
187+
await assert.rejects(fs.promises.rm(dir), { syscall: 'rm' });
188+
await assert.rejects(fs.promises.rm(dir, { recursive: false }), {
189189
syscall: 'rm'
190190
});
191191

192192
// Recursive removal should succeed.
193193
await fs.promises.rm(dir, { recursive: true });
194194

195195
// Attempted removal should fail now because the directory is gone.
196-
assert.rejects(fs.promises.rm(dir), { syscall: 'stat' });
196+
await assert.rejects(fs.promises.rm(dir), { syscall: 'stat' });
197197

198198
// Should fail if target does not exist
199-
assert.rejects(fs.promises.rm(
199+
await assert.rejects(fs.promises.rm(
200200
path.join(tmpdir.path, 'noexist.txt'),
201201
{ recursive: true }
202202
), {
@@ -206,7 +206,7 @@ function removeAsync(dir) {
206206
});
207207

208208
// Should not fail if target does not exist and force option is true
209-
fs.promises.rm(path.join(tmpdir.path, 'noexist.txt'), { force: true });
209+
await fs.promises.rm(path.join(tmpdir.path, 'noexist.txt'), { force: true });
210210

211211
// Should delete file
212212
const filePath = path.join(tmpdir.path, 'rm-promises-file.txt');

test/parallel/test-fs-rmdir-recursive.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ function removeAsync(dir) {
141141
makeNonEmptyDirectory(4, 10, 2, dir, true);
142142

143143
// Removal should fail without the recursive option set to true.
144-
assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
145-
assert.rejects(fs.promises.rmdir(dir, { recursive: false }), {
144+
await assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
145+
await assert.rejects(fs.promises.rmdir(dir, { recursive: false }), {
146146
syscall: 'rmdir'
147147
});
148148

@@ -154,7 +154,7 @@ function removeAsync(dir) {
154154
{ code: 'ENOENT' });
155155

156156
// Attempted removal should fail now because the directory is gone.
157-
assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
157+
await assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });
158158
})().then(common.mustCall());
159159

160160
// Test input validation.

0 commit comments

Comments
 (0)