◐ Shell
clean mode source ↗

test: deflake test-blob-file-backed · nodejs/node@be94e47

@@ -21,13 +21,17 @@ const tmpdir = require('../common/tmpdir');

2121

const testfile = tmpdir.resolve('test-file-backed-blob.txt');

2222

const testfile2 = tmpdir.resolve('test-file-backed-blob2.txt');

2323

const testfile3 = tmpdir.resolve('test-file-backed-blob3.txt');

24+

const testfile4 = tmpdir.resolve('test-file-backed-blob4.txt');

25+

const testfile5 = tmpdir.resolve('test-file-backed-blob5.txt');

2426

tmpdir.refresh();

25272628

const data = `${'a'.repeat(1000)}${'b'.repeat(2000)}`;

27292830

writeFileSync(testfile, data);

29-

writeFileSync(testfile2, data.repeat(100));

30-

writeFileSync(testfile3, '');

31+

writeFileSync(testfile2, data);

32+

writeFileSync(testfile3, data.repeat(100));

33+

writeFileSync(testfile4, '');

34+

writeFileSync(testfile5, '');

31353236

(async () => {

3337

const blob = await openAsBlob(testfile);

@@ -69,7 +73,7 @@ writeFileSync(testfile3, '');

69737074

(async () => {

7175

// Refs: https://github.com/nodejs/node/issues/47683

72-

const blob = await openAsBlob(testfile);

76+

const blob = await openAsBlob(testfile2);

7377

const res = blob.slice(10, 20);

7478

const ab = await res.arrayBuffer();

7579

strictEqual(res.size, ab.byteLength);

@@ -82,39 +86,41 @@ writeFileSync(testfile3, '');

82868387

const res1 = blob.slice(995, 1005);

8488

strictEqual(await res1.text(), data.slice(995, 1005));

89+

await unlink(testfile2);

8590

})().then(common.mustCall());

86918792

(async () => {

88-

const blob = await openAsBlob(testfile2);

93+

const blob = await openAsBlob(testfile3);

8994

const stream = blob.stream();

9095

const read = async () => {

9196

// eslint-disable-next-line no-unused-vars

9297

for await (const _ of stream) {

93-

writeFileSync(testfile2, data + 'abc');

98+

writeFileSync(testfile3, data + 'abc');

9499

}

95100

};

9610197102

await rejects(read(), { name: 'NotReadableError' });

9810399-

await unlink(testfile2);

104+

await unlink(testfile3);

100105

})().then(common.mustCall());

101106102107

(async () => {

103-

const blob = await openAsBlob(testfile3);

108+

const blob = await openAsBlob(testfile4);

104109

strictEqual(blob.size, 0);

105110

strictEqual(await blob.text(), '');

106-

writeFileSync(testfile3, 'abc');

111+

writeFileSync(testfile4, 'abc');

107112

await rejects(blob.text(), { name: 'NotReadableError' });

108-

await unlink(testfile3);

113+

await unlink(testfile4);

109114

})().then(common.mustCall());

110115111116

(async () => {

112-

const blob = await openAsBlob(testfile3);

117+

const blob = await openAsBlob(testfile5);

113118

strictEqual(blob.size, 0);

114-

writeFileSync(testfile3, 'abc');

119+

writeFileSync(testfile5, 'abc');

115120

const stream = blob.stream();

116121

const reader = stream.getReader();

117122

await rejects(() => reader.read(), { name: 'NotReadableError' });

123+

await unlink(testfile5);

118124

})().then(common.mustCall());

119125120126

(async () => {