MCPcopy Index your code
hub / github.com/nodejs/node / runTests

Function runTests

test/parallel/test-fastutf8stream-retry.js:30–77  ·  view source on GitHub ↗
(sync)

Source from the content-addressed store, hash-verified

28runTests(true);
29
30function runTests(sync) {
31 {
32 const dest = getTempFile();
33 const fd = openSync(dest, 'w');
34
35 const fsOverride = {};
36 let errOnNext = true;
37 const err = new Error('EAGAIN');
38 err.code = 'EAGAIN';
39 if (sync) {
40 fsOverride.writeSync = common.mustCall((...args) => {
41 if (errOnNext) {
42 errOnNext = false;
43 throw err;
44 }
45 writeSync(...args);
46 }, 3);
47 } else {
48 fsOverride.write = common.mustCall((...args) => {
49 if (errOnNext) {
50 errOnNext = false;
51 const callback = args[args.length - 1];
52 process.nextTick(callback, err);
53 return;
54 }
55 write(...args);
56 }, 3);
57 }
58
59 const stream = new Utf8Stream({
60 fd,
61 sync,
62 minLength: 0,
63 fs: fsOverride,
64 });
65
66 stream.on('ready', common.mustCall(() => {
67 assert.ok(stream.write('hello world\n'));
68 assert.ok(stream.write('something else\n'));
69 stream.end();
70 stream.on('finish', common.mustCall(() => {
71 readFile(dest, 'utf8', common.mustSucceed((data) => {
72 assert.strictEqual(data, 'hello world\nsomething else\n');
73 }));
74 }));
75 }));
76 }
77}
78
79{
80 const dest = getTempFile();

Callers 1

Calls 9

writeMethod · 0.95
endMethod · 0.95
getTempFileFunction · 0.70
openSyncFunction · 0.70
writeSyncFunction · 0.70
writeFunction · 0.70
readFileFunction · 0.70
onMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…