Skip to content

Commit 4f76ebe

Browse files
committed
test(dlx): add comprehensive cross-platform binary resolution tests
Add extensive test coverage for dlx binary resolution and CLI-style options: Binary resolution tests (dlx-package.test.ts): - Windows .cmd wrapper resolution - Windows .ps1 wrapper resolution - Windows .exe direct execution - Unix bare path usage (no wrappers) - Missing binary error handling - Single binary auto-selection - Multiple binaries with correct selection - Fallback to first binary when name doesn't match - Windows wrapper priority order (.cmd, .bat, .ps1, .exe, bare) Option interface tests: - yes flag (CLI-style, maps to force) - quiet flag (CLI-style, reserved for future use) - call flag (CLI-style, reserved for future use) - yes + force interaction DlxBinaryOptions tests (dlx-binary.test.ts): - yes flag force re-download behavior - quiet flag acceptance These tests verify: - Cross-platform compatibility (Windows vs Unix) - npm/npx binary resolution alignment - CLI-style option naming for cognitive consistency - Error handling for edge cases - Auto-detection logic for binary selection
1 parent 9358a86 commit 4f76ebe

2 files changed

Lines changed: 440 additions & 0 deletions

File tree

test/dlx-binary.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,55 @@ describe.sequential('dlx-binary', () => {
187187
}, 'dlxBinary-force-')
188188
})
189189

190+
it('should force re-download when yes option is true (CLI-style)', async () => {
191+
await runWithTempDir(async tmpDir => {
192+
const restoreHome = mockHomeDir(tmpDir)
193+
194+
try {
195+
const url = `${httpBaseUrl}/binary`
196+
197+
// First call
198+
const result1 = await dlxBinary(['--version'], {
199+
name: 'yes-binary',
200+
url,
201+
})
202+
await result1.spawnPromise.catch(() => {})
203+
204+
// Second call with yes (should behave like force)
205+
const result = await dlxBinary(['--version'], {
206+
name: 'yes-binary',
207+
url,
208+
yes: true,
209+
})
210+
expect(result.downloaded).toBe(true)
211+
await result.spawnPromise.catch(() => {})
212+
} finally {
213+
restoreHome()
214+
}
215+
}, 'dlxBinary-yes-')
216+
})
217+
218+
it('should accept quiet option (CLI-style, reserved)', async () => {
219+
await runWithTempDir(async tmpDir => {
220+
const restoreHome = mockHomeDir(tmpDir)
221+
222+
try {
223+
const url = `${httpBaseUrl}/binary`
224+
225+
// Call with quiet option - currently reserved for future use
226+
const result = await dlxBinary(['--version'], {
227+
name: 'quiet-binary',
228+
quiet: true,
229+
url,
230+
})
231+
expect(result.downloaded).toBe(true)
232+
await result.spawnPromise.catch(() => {})
233+
} finally {
234+
restoreHome()
235+
}
236+
}, 'dlxBinary-quiet-')
237+
})
238+
190239
it('should verify checksum when provided', async () => {
191240
await runWithTempDir(async tmpDir => {
192241
const restoreHome = mockHomeDir(tmpDir)

0 commit comments

Comments
 (0)