Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: fix test-fs-ut…
Browse files Browse the repository at this point in the history
…imes on non-Y2K38 file systems
  • Loading branch information
Trott committed Mar 17, 2021
1 parent 9c8b1ed commit 8d2095e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions test/parallel/test-fs-utimes-y2K38.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,27 @@ const fs = require('fs');

tmpdir.refresh();

// Check for Y2K38 support. For Windows, assume it's there. Windows doesn't have
// `touch`.
if (!common.isWindows) {
// Check for Y2K38 support. For Windows and AIX, assume it's there. Windows
// doesn't have `touch` and `date -r` which are used in the check for support.
// AIX lacks `date -r`.
if (!common.isWindows && !common.isAIX) {
const testFilePath = `${tmpdir.path}/y2k38-test`;
const testFileDate = '204001020304';
const { spawnSync } = require('child_process');
const { status } = spawnSync('touch',
['-t', testFileDate, testFilePath],
const touchResult = spawnSync('touch',
['-t', testFileDate, testFilePath],
{ encoding: 'utf8' });
if (touchResult.status !== 0) {
common.skip('File system appears to lack Y2K38 support (touch failed)');
}

const dateResult = spawnSync('date',
['-r', testFilePath, '+%Y%m%d%H%M'],
{ encoding: 'utf8' });
if (status !== 0) {
common.skip('File system appears to lack Y2K38 support');

assert.strictEqual(dateResult.status, 0);
if (dateResult.stdout.trim() !== testFileDate) {
common.skip('File system appears to lack Y2k38 support (date failed)');
}
}

Expand Down

0 comments on commit 8d2095e

Please sign in to comment.