From 8d2095e7b5fb986b43b2b047be93808d581ca886 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 17 Mar 2021 08:53:45 -0700 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: fix test-fs-utimes on non-Y2K38 file systems --- test/parallel/test-fs-utimes-y2K38.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-utimes-y2K38.js b/test/parallel/test-fs-utimes-y2K38.js index 860fcb31860b78..5dc4bbcd6c5412 100644 --- a/test/parallel/test-fs-utimes-y2K38.js +++ b/test/parallel/test-fs-utimes-y2K38.js @@ -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)'); } }