Skip to content

Commit 6b9d2ae

Browse files
bcoemhdawson
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 8de858b commit 6b9d2ae

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
@@ -185,19 +185,19 @@ function removeAsync(dir) {
185185
makeNonEmptyDirectory(4, 10, 2, dir, true);
186186

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

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

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

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

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

212212
// Should delete file
213213
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)