| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9166653 commit e57e532
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,20 +1,15 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | ||
| 4 | - if (common.isIBMi) { | ||
| 5 | - common.skip('fs.utimesSync() currently fails on IBM i with Y2K38 values'); | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | 4 | const tmpdir = require('../common/tmpdir'); | |
| 9 | 5 | tmpdir.refresh(); | |
| 10 | 6 | ||
| 11 | 7 | const assert = require('assert'); | |
| 12 | 8 | const fs = require('fs'); | |
| 13 | 9 | ||
| 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 | ||
| 15 | 11 | // 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) { | ||
| 18 | 13 | const testFilePath = `${tmpdir.path}/y2k38-test`; | |
| 19 | 14 | const testFileDate = '204001020304'; | |
| 20 | 15 | const { spawnSync } = require('child_process'); | |
@@ -25,13 +20,21 @@ if (!common.isWindows && !common.isAIX) { | |||
| 25 | 20 | common.skip('File system appears to lack Y2K38 support (touch failed)'); | |
| 26 | 21 | } | |
| 27 | 22 | ||
| 23 | + // On some file systems that lack Y2K38 support, `touch` will succeed but | ||
| 24 | + // the time will be incorrect. | ||
| 28 | 25 | const dateResult = spawnSync('date', | |
| 29 | 26 | ['-r', testFilePath, '+%Y%m%d%H%M'], | |
| 30 | 27 | { 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:/); | ||
| 35 | 38 | } | |
| 36 | 39 | } | |
| 37 | 40 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments