Skip to content

Commit 4a84072

Browse files
committed
fix(test): skip Unix permission checks on Windows
- Add platform checks to skip Unix permission tests on Windows - Windows doesn't preserve Unix execute bits (owner/group/others) the same way - Fixes 3 test failures on Windows: - extractBinaryFromTarball: executable bit check - extractBinaryFromTarball: preserve executable bit check - extractTarball: file permissions check - Tests still run fully on Unix/Linux/macOS platforms
1 parent d2dc5ac commit 4a84072

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

packages/cli/src/utils/registry/npm-registry.integration.test.mts

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ describe('integration-lite: tarball extraction', () => {
9292
expect(result).toBe(outputPath)
9393
expect(await fs.readFile(outputPath, 'utf8')).toContain('console.log')
9494

95-
// Check permissions (executable bit).
96-
const stats = await fs.stat(outputPath)
97-
expect(stats.mode & 0o111).toBeTruthy() // Has execute permission.
95+
// Check permissions (executable bit) - Unix only.
96+
// Windows doesn't preserve Unix execute bits the same way.
97+
if (process.platform !== 'win32') {
98+
const stats = await fs.stat(outputPath)
99+
expect(stats.mode & 0o111).toBeTruthy() // Has execute permission.
100+
}
98101
})
99102

100103
it('should handle package/ prefix correctly', async () => {
@@ -136,12 +139,15 @@ describe('integration-lite: tarball extraction', () => {
136139
const outputPath = path.join(tempDir, 'socket')
137140
await extractBinaryFromTarball(tarballPath, 'bin/socket', outputPath)
138141

139-
const stats = await fs.stat(outputPath)
142+
// Check all execute bits (owner, group, others) - Unix only.
143+
// Windows doesn't preserve Unix execute bits the same way.
144+
if (process.platform !== 'win32') {
145+
const stats = await fs.stat(outputPath)
140146

141-
// Check all execute bits (owner, group, others).
142-
expect(stats.mode & 0o100).toBeTruthy() // Owner execute.
143-
expect(stats.mode & 0o010).toBeTruthy() // Group execute.
144-
expect(stats.mode & 0o001).toBeTruthy() // Others execute.
147+
expect(stats.mode & 0o100).toBeTruthy() // Owner execute.
148+
expect(stats.mode & 0o010).toBeTruthy() // Group execute.
149+
expect(stats.mode & 0o001).toBeTruthy() // Others execute.
150+
}
145151
})
146152

147153
it('should handle nested directories', async () => {
@@ -282,18 +288,22 @@ describe('integration-lite: tarball extraction', () => {
282288

283289
await extractTarball(tarballPath, extractDir)
284290

285-
const readonlyStats = await fs.stat(
286-
path.join(extractDir, 'readonly.txt'),
287-
)
288-
const executableStats = await fs.stat(
289-
path.join(extractDir, 'executable.sh'),
290-
)
291-
292-
// Read-only file.
293-
expect(readonlyStats.mode & 0o200).toBe(0) // No write permission.
294-
295-
// Executable file.
296-
expect(executableStats.mode & 0o111).toBeTruthy() // Execute permission.
291+
// Check file permissions - Unix only.
292+
// Windows doesn't preserve Unix permissions the same way.
293+
if (process.platform !== 'win32') {
294+
const readonlyStats = await fs.stat(
295+
path.join(extractDir, 'readonly.txt'),
296+
)
297+
const executableStats = await fs.stat(
298+
path.join(extractDir, 'executable.sh'),
299+
)
300+
301+
// Read-only file.
302+
expect(readonlyStats.mode & 0o200).toBe(0) // No write permission.
303+
304+
// Executable file.
305+
expect(executableStats.mode & 0o111).toBeTruthy() // Execute permission.
306+
}
297307
})
298308

299309
it('should create parent directories', async () => {

0 commit comments

Comments
 (0)