Skip to content

Commit 44490af

Browse files
richardlauruyadorno
authored andcommitted
test: relax Y2K38 check in test-fs-utimes-y2K38
On some platforms `date` may not support the `-r` option. Optimistically allow the test to proceed in that case as the previous `touch` had succeeded -- we were just not able to easily validate the file date. PR-URL: #37825 Refs: #37707 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent cdfc1c8 commit 44490af

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

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

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
'use strict';
22
const common = require('../common');
33

4-
if (common.isIBMi) {
5-
common.skip('fs.utimesSync() currently fails on IBM i with Y2K38 values');
6-
}
7-
84
const tmpdir = require('../common/tmpdir');
95
tmpdir.refresh();
106

117
const assert = require('assert');
128
const fs = require('fs');
139

14-
// Check for Y2K38 support. For Windows and AIX, assume it's there. Windows
10+
// Check for Y2K38 support. For Windows, assume it's there. Windows
1511
// doesn't have `touch` and `date -r` which are used in the check for support.
16-
// AIX lacks `date -r`.
17-
if (!common.isWindows && !common.isAIX) {
12+
if (!common.isWindows) {
1813
const testFilePath = `${tmpdir.path}/y2k38-test`;
1914
const testFileDate = '204001020304';
2015
const { spawnSync } = require('child_process');
@@ -25,13 +20,21 @@ if (!common.isWindows && !common.isAIX) {
2520
common.skip('File system appears to lack Y2K38 support (touch failed)');
2621
}
2722

23+
// On some file systems that lack Y2K38 support, `touch` will succeed but
24+
// the time will be incorrect.
2825
const dateResult = spawnSync('date',
2926
['-r', testFilePath, '+%Y%m%d%H%M'],
3027
{ encoding: 'utf8' });
31-
32-
assert.strictEqual(dateResult.status, 0);
33-
if (dateResult.stdout.trim() !== testFileDate) {
34-
common.skip('File system appears to lack Y2k38 support (date failed)');
28+
if (dateResult.status === 0) {
29+
if (dateResult.stdout.trim() !== testFileDate) {
30+
common.skip('File system appears to lack Y2k38 support (date failed)');
31+
}
32+
} else {
33+
// On some platforms `date` may not support the `-r` option. Usually
34+
// this will result in a non-zero status and usage information printed.
35+
// In this case optimistically proceed -- the earlier `touch` succeeded
36+
// but validation that the file has the correct time is not easily possible.
37+
assert.match(dateResult.stderr, /[Uu]sage:/);
3538
}
3639
}
3740

0 commit comments

Comments
 (0)