Skip to content

Commit 6225ba8

Browse files
authored
Merge pull request #390 from everett1992/done
fix timeout in failing test
2 parents b0808c5 + c5f5d5f commit 6225ba8

20 files changed

+510
-324
lines changed

test/lib/fs.appendFile.spec.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ describe('fs.appendFile(filename, data, [options], callback)', function () {
2626
});
2727

2828
it('promise writes a string to a new file', function (done) {
29-
fs.promises.appendFile('foo', 'bar').then(function () {
30-
assert.equal(String(fs.readFileSync('foo')), 'bar');
31-
done();
32-
}, done);
29+
fs.promises
30+
.appendFile('foo', 'bar')
31+
.then(function () {
32+
assert.equal(String(fs.readFileSync('foo')), 'bar');
33+
done();
34+
})
35+
.catch(done);
3336
});
3437

3538
it('appends a string to an existing file', function (done) {
@@ -43,10 +46,16 @@ describe('fs.appendFile(filename, data, [options], callback)', function () {
4346
});
4447

4548
it('promise appends a string to an existing file', function (done) {
46-
fs.promises.appendFile('dir/file.txt', ' bar').then(function () {
47-
assert.equal(String(fs.readFileSync('dir/file.txt')), 'file content bar');
48-
done();
49-
}, done);
49+
fs.promises
50+
.appendFile('dir/file.txt', ' bar')
51+
.then(function () {
52+
assert.equal(
53+
String(fs.readFileSync('dir/file.txt')),
54+
'file content bar'
55+
);
56+
done();
57+
})
58+
.catch(done);
5059
});
5160

5261
it('appends a buffer to a file', function (done) {
@@ -68,7 +77,8 @@ describe('fs.appendFile(filename, data, [options], callback)', function () {
6877
'file content bar'
6978
);
7079
done();
71-
}, done);
80+
})
81+
.catch(done);
7282
});
7383

7484
it('appends via a symbolic link file', function (done) {
@@ -82,10 +92,16 @@ describe('fs.appendFile(filename, data, [options], callback)', function () {
8292
});
8393

8494
it('promise appends via a symbolic link file', function (done) {
85-
fs.promises.appendFile('link.txt', ' bar').then(function () {
86-
assert.equal(String(fs.readFileSync('dir/file.txt')), 'file content bar');
87-
done();
88-
}, done);
95+
fs.promises
96+
.appendFile('link.txt', ' bar')
97+
.then(function () {
98+
assert.equal(
99+
String(fs.readFileSync('dir/file.txt')),
100+
'file content bar'
101+
);
102+
done();
103+
})
104+
.catch(done);
89105
});
90106

91107
it('fails if directory does not exist', function (done) {

test/lib/fs.chmod-fchmod.spec.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ describe('fs.chmod(path, mode, callback)', function () {
3737
});
3838

3939
it('promise changes permissions of a file', function (done) {
40-
fs.promises.chmod('file.txt', parseInt('0664', 8)).then(function () {
41-
const stats = fs.statSync('file.txt');
42-
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0664', 8));
43-
done();
44-
}, done);
40+
fs.promises
41+
.chmod('file.txt', parseInt('0664', 8))
42+
.then(function () {
43+
const stats = fs.statSync('file.txt');
44+
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0664', 8));
45+
done();
46+
})
47+
.catch(done);
4548
});
4649

4750
it('fails if file does not exist', function (done) {
@@ -117,7 +120,8 @@ describe('fs.fchmod(fd, mode, callback)', function () {
117120
const stats = fs.statSync('file.txt');
118121
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0644', 8));
119122
done();
120-
}, done);
123+
})
124+
.catch(done);
121125
});
122126
});
123127

test/lib/fs.copyFile.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ if (fs.copyFile && fs.copyFileSync) {
5252
'file content'
5353
);
5454
done();
55-
}, done);
55+
})
56+
.catch(done);
5657
});
5758

5859
it('truncates dest file if it exists', function (done) {
@@ -75,7 +76,8 @@ if (fs.copyFile && fs.copyFileSync) {
7576
'file content'
7677
);
7778
done();
78-
}, done);
79+
})
80+
.catch(done);
7981
});
8082

8183
it('throws if dest exists and exclusive', function (done) {

test/lib/fs.link-symlink.spec.js

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ describe('fs.link(srcpath, dstpath, callback)', function () {
4949
it('promise creates a link to a file', function (done) {
5050
assert.equal(fs.statSync('file.txt').nlink, 1);
5151

52-
fs.promises.link('file.txt', 'link.txt').then(function () {
53-
assert.isTrue(fs.statSync('link.txt').isFile());
54-
assert.equal(fs.statSync('link.txt').nlink, 2);
55-
assert.equal(fs.statSync('file.txt').nlink, 2);
56-
assert.equal(String(fs.readFileSync('link.txt')), 'content');
57-
done();
58-
}, done);
52+
fs.promises
53+
.link('file.txt', 'link.txt')
54+
.then(function () {
55+
assert.isTrue(fs.statSync('link.txt').isFile());
56+
assert.equal(fs.statSync('link.txt').nlink, 2);
57+
assert.equal(fs.statSync('file.txt').nlink, 2);
58+
assert.equal(String(fs.readFileSync('link.txt')), 'content');
59+
done();
60+
})
61+
.catch(done);
5962
});
6063

6164
it('works if original is renamed', function (done) {
@@ -71,12 +74,15 @@ describe('fs.link(srcpath, dstpath, callback)', function () {
7174
});
7275

7376
it('promise works if original is renamed', function (done) {
74-
fs.promises.link('file.txt', 'link.txt').then(function () {
75-
fs.renameSync('file.txt', 'renamed.txt');
76-
assert.isTrue(fs.statSync('link.txt').isFile());
77-
assert.equal(String(fs.readFileSync('link.txt')), 'content');
78-
done();
79-
}, done);
77+
fs.promises
78+
.link('file.txt', 'link.txt')
79+
.then(function () {
80+
fs.renameSync('file.txt', 'renamed.txt');
81+
assert.isTrue(fs.statSync('link.txt').isFile());
82+
assert.equal(String(fs.readFileSync('link.txt')), 'content');
83+
done();
84+
})
85+
.catch(done);
8086
});
8187

8288
it('works if original is removed', function (done) {
@@ -99,15 +105,18 @@ describe('fs.link(srcpath, dstpath, callback)', function () {
99105
it('promise works if original is removed', function (done) {
100106
assert.equal(fs.statSync('file.txt').nlink, 1);
101107

102-
fs.promises.link('file.txt', 'link.txt').then(function () {
103-
assert.equal(fs.statSync('link.txt').nlink, 2);
104-
assert.equal(fs.statSync('file.txt').nlink, 2);
105-
fs.unlinkSync('file.txt');
106-
assert.isTrue(fs.statSync('link.txt').isFile());
107-
assert.equal(fs.statSync('link.txt').nlink, 1);
108-
assert.equal(String(fs.readFileSync('link.txt')), 'content');
109-
done();
110-
}, done);
108+
fs.promises
109+
.link('file.txt', 'link.txt')
110+
.then(function () {
111+
assert.equal(fs.statSync('link.txt').nlink, 2);
112+
assert.equal(fs.statSync('file.txt').nlink, 2);
113+
fs.unlinkSync('file.txt');
114+
assert.isTrue(fs.statSync('link.txt').isFile());
115+
assert.equal(fs.statSync('link.txt').nlink, 1);
116+
assert.equal(String(fs.readFileSync('link.txt')), 'content');
117+
done();
118+
})
119+
.catch(done);
111120
});
112121

113122
it('fails if original is a directory', function (done) {
@@ -221,11 +230,14 @@ describe('fs.symlink(srcpath, dstpath, [type], callback)', function () {
221230
}
222231

223232
it('promise creates a symbolic link to a file', function (done) {
224-
fs.promises.symlink('../file.txt', 'dir/link.txt').then(function () {
225-
assert.isTrue(fs.statSync('dir/link.txt').isFile());
226-
assert.equal(String(fs.readFileSync('dir/link.txt')), 'content');
227-
done();
228-
}, done);
233+
fs.promises
234+
.symlink('../file.txt', 'dir/link.txt')
235+
.then(function () {
236+
assert.isTrue(fs.statSync('dir/link.txt').isFile());
237+
assert.equal(String(fs.readFileSync('dir/link.txt')), 'content');
238+
done();
239+
})
240+
.catch(done);
229241
});
230242

231243
it('breaks if original is renamed', function (done) {
@@ -241,12 +253,15 @@ describe('fs.symlink(srcpath, dstpath, [type], callback)', function () {
241253
});
242254

243255
it('promise breaks if original is renamed', function (done) {
244-
fs.promises.symlink('file.txt', 'link.txt').then(function () {
245-
assert.isTrue(fs.existsSync('link.txt'));
246-
fs.renameSync('file.txt', 'renamed.txt');
247-
assert.isFalse(fs.existsSync('link.txt'));
248-
done();
249-
}, done);
256+
fs.promises
257+
.symlink('file.txt', 'link.txt')
258+
.then(function () {
259+
assert.isTrue(fs.existsSync('link.txt'));
260+
fs.renameSync('file.txt', 'renamed.txt');
261+
assert.isFalse(fs.existsSync('link.txt'));
262+
done();
263+
})
264+
.catch(done);
250265
});
251266

252267
it('works if original is a directory', function (done) {
@@ -260,10 +275,13 @@ describe('fs.symlink(srcpath, dstpath, [type], callback)', function () {
260275
});
261276

262277
it('promise works if original is a directory', function (done) {
263-
fs.promises.symlink('dir', 'link').then(function () {
264-
assert.isTrue(fs.statSync('link').isDirectory());
265-
done();
266-
}, done);
278+
fs.promises
279+
.symlink('dir', 'link')
280+
.then(function () {
281+
assert.isTrue(fs.statSync('link').isDirectory());
282+
done();
283+
})
284+
.catch(done);
267285
});
268286
});
269287

test/lib/fs.lstat.spec.js

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,27 @@ describe('fs.lstat(path, options, callback)', function () {
7070
});
7171

7272
it('promise stats a symbolic link', function (done) {
73-
fs.promises.lstat('link').then(function (stats) {
74-
assert.isTrue(stats.isSymbolicLink());
75-
assert.isFalse(stats.isFile());
76-
assert.equal(stats.mtime.getTime(), 2);
77-
done();
78-
}, done);
73+
fs.promises
74+
.lstat('link')
75+
.then(function (stats) {
76+
assert.isTrue(stats.isSymbolicLink());
77+
assert.isFalse(stats.isFile());
78+
assert.equal(stats.mtime.getTime(), 2);
79+
done();
80+
})
81+
.catch(done);
7982
});
8083

8184
it('promise stats a symbolic link with bigint', function (done) {
82-
fs.promises.lstat('link', {bigint: true}).then(function (stats) {
83-
assert.isTrue(stats.isSymbolicLink());
84-
assert.isFalse(stats.isFile());
85-
assert.equal(typeof stats.mtimeMs, 'bigint');
86-
done();
87-
}, done);
85+
fs.promises
86+
.lstat('link', {bigint: true})
87+
.then(function (stats) {
88+
assert.isTrue(stats.isSymbolicLink());
89+
assert.isFalse(stats.isFile());
90+
assert.equal(typeof stats.mtimeMs, 'bigint');
91+
done();
92+
})
93+
.catch(done);
8894
});
8995

9096
it('stats a regular file', function (done) {
@@ -112,21 +118,27 @@ describe('fs.lstat(path, options, callback)', function () {
112118
});
113119

114120
it('promise stats a regular file', function (done) {
115-
fs.promises.lstat('file.txt').then(function (stats) {
116-
assert.isTrue(stats.isFile());
117-
assert.isFalse(stats.isSymbolicLink());
118-
assert.equal(stats.mtime.getTime(), 1);
119-
done();
120-
}, done);
121+
fs.promises
122+
.lstat('file.txt')
123+
.then(function (stats) {
124+
assert.isTrue(stats.isFile());
125+
assert.isFalse(stats.isSymbolicLink());
126+
assert.equal(stats.mtime.getTime(), 1);
127+
done();
128+
})
129+
.catch(done);
121130
});
122131

123132
it('promise stats a regular file with bigint', function (done) {
124-
fs.promises.lstat('file.txt', {bigint: true}).then(function (stats) {
125-
assert.isTrue(stats.isFile());
126-
assert.isFalse(stats.isSymbolicLink());
127-
assert.equal(typeof stats.mtimeMs, 'bigint');
128-
done();
129-
}, done);
133+
fs.promises
134+
.lstat('file.txt', {bigint: true})
135+
.then(function (stats) {
136+
assert.isTrue(stats.isFile());
137+
assert.isFalse(stats.isSymbolicLink());
138+
assert.equal(typeof stats.mtimeMs, 'bigint');
139+
done();
140+
})
141+
.catch(done);
130142
});
131143

132144
it('fails on file not exist', function (done) {

test/lib/fs.mkdir.spec.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ describe('fs.mkdir(path, [mode], callback)', function () {
4444
});
4545

4646
it('promise creates a new directory', function (done) {
47-
fs.promises.mkdir('parent/dir').then(function () {
48-
const stats = fs.statSync('parent/dir');
49-
assert.isTrue(stats.isDirectory());
50-
done();
51-
}, done);
47+
fs.promises
48+
.mkdir('parent/dir')
49+
.then(function () {
50+
const stats = fs.statSync('parent/dir');
51+
assert.isTrue(stats.isDirectory());
52+
done();
53+
})
54+
.catch(done);
5255
});
5356

5457
it('creates a new directory recursively', function (done) {
@@ -77,7 +80,8 @@ describe('fs.mkdir(path, [mode], callback)', function () {
7780
stats = fs.statSync('parent/foo');
7881
assert.isTrue(stats.isDirectory());
7982
done();
80-
}, done);
83+
})
84+
.catch(done);
8185
});
8286

8387
it('accepts dir mode', function (done) {
@@ -93,12 +97,15 @@ describe('fs.mkdir(path, [mode], callback)', function () {
9397
});
9498

9599
it('promise accepts dir mode', function (done) {
96-
fs.promises.mkdir('parent/dir', parseInt('0755', 8)).then(function () {
97-
const stats = fs.statSync('parent/dir');
98-
assert.isTrue(stats.isDirectory());
99-
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0755', 8));
100-
done();
101-
}, done);
100+
fs.promises
101+
.mkdir('parent/dir', parseInt('0755', 8))
102+
.then(function () {
103+
const stats = fs.statSync('parent/dir');
104+
assert.isTrue(stats.isDirectory());
105+
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0755', 8));
106+
done();
107+
})
108+
.catch(done);
102109
});
103110

104111
it('accepts dir mode recursively', function (done) {
@@ -141,7 +148,8 @@ describe('fs.mkdir(path, [mode], callback)', function () {
141148
assert.isTrue(stats.isDirectory());
142149
assert.equal(stats.mode & parseInt('0777', 8), parseInt('0755', 8));
143150
done();
144-
}, done);
151+
})
152+
.catch(done);
145153
});
146154

147155
it('fails if parent does not exist', function (done) {

0 commit comments

Comments
 (0)