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

Function runTests

test/parallel/test-fs-utimes.js:95–168  ·  view source on GitHub ↗
(iter)

Source from the content-addressed store, hash-verified

93runTests(cases.values());
94
95function runTests(iter) {
96 const { value, done } = iter.next();
97 if (done) return;
98
99 // Support easy setting same or different atime / mtime values.
100 const [pathType, atime, mtime = atime] = value;
101
102 let fd;
103 //
104 // test async code paths
105 //
106 const expectedUtimesMtime = getExpectedMtime(mtime);
107 fs.utimes(pathType(tmpdir.path), atime, mtime, common.mustCall((err) => {
108 expect_ok('utimes', tmpdir.path, err, atime, expectedUtimesMtime);
109
110 const expectedLutimesMtime = getExpectedMtime(mtime);
111 fs.lutimes(pathType(lpath), atime, mtime, common.mustCall((err) => {
112 expect_ok('lutimes', lpath, err, atime, expectedLutimesMtime, fs.lstatSync);
113
114 fs.utimes(pathType('foobarbaz'), atime, mtime, common.mustCall((err) => {
115 expect_errno('utimes', 'foobarbaz', err, 'ENOENT');
116
117 // don't close this fd
118 if (common.isWindows) {
119 fd = fs.openSync(tmpdir.path, 'r+');
120 } else {
121 fd = fs.openSync(tmpdir.path, 'r');
122 }
123
124 const expectedFutimesMtime = getExpectedMtime(mtime);
125 fs.futimes(fd, atime, mtime, common.mustCall((err) => {
126 expect_ok('futimes', fd, err, atime, expectedFutimesMtime);
127
128 syncTests();
129
130 setImmediate(common.mustCall(runTests), iter);
131 }));
132 }));
133 }));
134 }));
135
136 //
137 // test synchronized code paths, these functions throw on failure
138 //
139 function syncTests() {
140 const expectedUtimesMtime = getExpectedMtime(mtime);
141 fs.utimesSync(pathType(tmpdir.path), atime, mtime);
142 expect_ok('utimesSync', tmpdir.path, undefined, atime, expectedUtimesMtime);
143
144 const expectedLutimesMtime = getExpectedMtime(mtime);
145 fs.lutimesSync(pathType(lpath), atime, mtime);
146 expect_ok('lutimesSync', lpath, undefined, atime, expectedLutimesMtime, fs.lstatSync);
147
148 // Some systems don't have futimes
149 // if there's an error, it should be ENOSYS
150 try {
151 const expectedFutimesMtime = getExpectedMtime(mtime);
152 fs.futimesSync(fd, atime, mtime);

Callers 1

test-fs-utimes.jsFile · 0.70

Calls 9

getExpectedMtimeFunction · 0.85
expect_okFunction · 0.85
expect_errnoFunction · 0.85
syncTestsFunction · 0.85
lutimesMethod · 0.80
nextMethod · 0.65
setImmediateFunction · 0.50
utimesMethod · 0.45
openSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…