(atime, mtime, margin = 0)
| 50 | } |
| 51 | |
| 52 | async function runTest(atime, mtime, margin = 0) { |
| 53 | margin += Number.EPSILON; |
| 54 | try { |
| 55 | await fsPromises.utimes(filepath, new Date(atime), new Date(mtime)); |
| 56 | } catch (e) { |
| 57 | if (ignoredErrors.has(e.code)) return; |
| 58 | throw e; |
| 59 | } |
| 60 | |
| 61 | const stats = await fsPromises.stat(filepath); |
| 62 | closeEnough(stats.atimeMs, atime, margin); |
| 63 | closeEnough(stats.mtimeMs, mtime, margin); |
| 64 | closeEnough(stats.atime.getTime(), new Date(atime).getTime(), margin); |
| 65 | closeEnough(stats.mtime.getTime(), new Date(mtime).getTime(), margin); |
| 66 | validateEnumerability(stats); |
| 67 | |
| 68 | const statsBigint = await fsPromises.stat(filepath, { bigint: true }); |
| 69 | closeEnough(statsBigint.atimeMs, BigInt(atime), margin); |
| 70 | closeEnough(statsBigint.mtimeMs, BigInt(mtime), margin); |
| 71 | closeEnough(statsBigint.atime.getTime(), new Date(atime).getTime(), margin); |
| 72 | closeEnough(statsBigint.mtime.getTime(), new Date(mtime).getTime(), margin); |
| 73 | validateEnumerability(statsBigint); |
| 74 | |
| 75 | const statsSync = fs.statSync(filepath); |
| 76 | closeEnough(statsSync.atimeMs, atime, margin); |
| 77 | closeEnough(statsSync.mtimeMs, mtime, margin); |
| 78 | closeEnough(statsSync.atime.getTime(), new Date(atime).getTime(), margin); |
| 79 | closeEnough(statsSync.mtime.getTime(), new Date(mtime).getTime(), margin); |
| 80 | validateEnumerability(statsSync); |
| 81 | |
| 82 | const statsSyncBigint = fs.statSync(filepath, { bigint: true }); |
| 83 | closeEnough(statsSyncBigint.atimeMs, BigInt(atime), margin); |
| 84 | closeEnough(statsSyncBigint.mtimeMs, BigInt(mtime), margin); |
| 85 | closeEnough(statsSyncBigint.atime.getTime(), new Date(atime).getTime(), margin); |
| 86 | closeEnough(statsSyncBigint.mtime.getTime(), new Date(mtime).getTime(), margin); |
| 87 | validateEnumerability(statsSyncBigint); |
| 88 | } |
| 89 | |
| 90 | // Too high/low numbers produce too different results on different platforms |
| 91 | { |
no test coverage detected
searching dependent graphs…