GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: capture negative utimes mtime at call time · nodejs/node@4097fb9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-fs-utimes.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-fs-utimes.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-utimes.js
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ function expect_ok(syscall, resource, err, atime, mtime, statSync) {
7070
);
7171
}
7272

73+
function getExpectedMtime(mtime) {
74+
// Negative numeric timestamps are normalized to "now" at call time.
75+
return fs._toUnixTimestamp(mtime);
76+
}
77+
7378
const stats = fs.statSync(tmpdir.path);
7479

7580
const asPath = (path) => path;
@@ -98,11 +103,13 @@ function runTests(iter) {
98103
//
99104
// test async code paths
100105
//
106+
const expectedUtimesMtime = getExpectedMtime(mtime);
101107
fs.utimes(pathType(tmpdir.path), atime, mtime, common.mustCall((err) => {
102-
expect_ok('utimes', tmpdir.path, err, atime, mtime);
108+
expect_ok('utimes', tmpdir.path, err, atime, expectedUtimesMtime);
103109

110+
const expectedLutimesMtime = getExpectedMtime(mtime);
104111
fs.lutimes(pathType(lpath), atime, mtime, common.mustCall((err) => {
105-
expect_ok('lutimes', lpath, err, atime, mtime, fs.lstatSync);
112+
expect_ok('lutimes', lpath, err, atime, expectedLutimesMtime, fs.lstatSync);
106113

107114
fs.utimes(pathType('foobarbaz'), atime, mtime, common.mustCall((err) => {
108115
expect_errno('utimes', 'foobarbaz', err, 'ENOENT');
@@ -114,8 +121,9 @@ function runTests(iter) {
114121
fd = fs.openSync(tmpdir.path, 'r');
115122
}
116123

124+
const expectedFutimesMtime = getExpectedMtime(mtime);
117125
fs.futimes(fd, atime, mtime, common.mustCall((err) => {
118-
expect_ok('futimes', fd, err, atime, mtime);
126+
expect_ok('futimes', fd, err, atime, expectedFutimesMtime);
119127

120128
syncTests();
121129

@@ -129,17 +137,20 @@ function runTests(iter) {
129137
// test synchronized code paths, these functions throw on failure
130138
//
131139
function syncTests() {
140+
const expectedUtimesMtime = getExpectedMtime(mtime);
132141
fs.utimesSync(pathType(tmpdir.path), atime, mtime);
133-
expect_ok('utimesSync', tmpdir.path, undefined, atime, mtime);
142+
expect_ok('utimesSync', tmpdir.path, undefined, atime, expectedUtimesMtime);
134143

144+
const expectedLutimesMtime = getExpectedMtime(mtime);
135145
fs.lutimesSync(pathType(lpath), atime, mtime);
136-
expect_ok('lutimesSync', lpath, undefined, atime, mtime, fs.lstatSync);
146+
expect_ok('lutimesSync', lpath, undefined, atime, expectedLutimesMtime, fs.lstatSync);
137147

138148
// Some systems don't have futimes
139149
// if there's an error, it should be ENOSYS
140150
try {
151+
const expectedFutimesMtime = getExpectedMtime(mtime);
141152
fs.futimesSync(fd, atime, mtime);
142-
expect_ok('futimesSync', fd, undefined, atime, mtime);
153+
expect_ok('futimesSync', fd, undefined, atime, expectedFutimesMtime);
143154
} catch (ex) {
144155
expect_errno('futimesSync', fd, ex, 'ENOSYS');
145156
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.