From 37f2bbf6c98bcc4dde0527e36b39f8dff026befa Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Tue, 15 Sep 2026 14:21:57 -0400 Subject: [PATCH] test: make directory identity mocks safe for Windows inodes --- tests/lib/context-profile-support.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/lib/context-profile-support.test.js b/tests/lib/context-profile-support.test.js index 997a2526a..06a28876a 100644 --- a/tests/lib/context-profile-support.test.js +++ b/tests/lib/context-profile-support.test.js @@ -34,10 +34,24 @@ function mockEnumeration(context, entriesFor) { function changedIdentity(stats) { const changed = Object.assign(Object.create(Object.getPrototypeOf(stats)), stats); - changed.ino = typeof stats.ino === 'bigint' ? stats.ino + 1n : stats.ino + 1; + // Windows inode numbers can exceed safe integer precision, so adding 1 may be a no-op. + const zero = typeof stats.ino === 'bigint' ? 0n : 0; + const one = typeof stats.ino === 'bigint' ? 1n : 1; + changed.ino = stats.ino === zero ? one : zero; return changed; } +test('identity mock changes inode values beyond safe integer precision', () => { + for (const ino of [0, 1, 2 ** 60, 0n, 1n, 2n ** 60n]) { + const stats = { ino, dev: 1, mode: 16877 }; + const changed = changedIdentity(stats); + assert.notEqual(changed.ino, stats.ino); + assert.equal(typeof changed.ino, typeof stats.ino); + assert.equal(changed.dev, stats.dev); + assert.equal(changed.mode, stats.mode); + } +}); + function samePath(left, right) { const normalize = value => path.resolve(value).toLowerCase(); return normalize(left) === normalize(right);