Skip to content

Commit

Permalink
skip xdg-open tests on wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
mbtools committed Oct 16, 2024
1 parent 9896bd3 commit 1bec1e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const spawk = require('spawk')
const t = require('tap')
const os = require('os')

const promiseSpawn = require('../lib/index.js')

Expand All @@ -10,6 +11,8 @@ t.afterEach(() => {
spawk.clean()
})

const isWSL = process.platform === 'linux' && os.release().toLowerCase().includes('microsoft')

t.test('process.platform === win32', (t) => {
const comSpec = process.env.ComSpec
const platformDesc = Object.getOwnPropertyDescriptor(process, 'platform')
Expand Down Expand Up @@ -118,7 +121,8 @@ t.test('process.platform === linux', (t) => {
Object.defineProperty(process, 'platform', platformDesc)
})

t.test('uses xdg-open in a shell', async (t) => {
// xdg-open is not installed in WSL by default
t.test('uses xdg-open in a shell', { skip: isWSL }, async (t) => {
const proc = spawk.spawn('sh', ['-c', 'xdg-open https://google.com'], { shell: false })

const result = await promiseSpawn.open('https://google.com')
Expand All @@ -130,7 +134,8 @@ t.test('process.platform === linux', (t) => {
t.ok(proc.called)
})

t.test('ignores shell = false', async (t) => {
// xdg-open is not installed in WSL by default
t.test('ignores shell = false', { skip: isWSL }, async (t) => {
const proc = spawk.spawn('sh', ['-c', 'xdg-open https://google.com'], { shell: false })

const result = await promiseSpawn.open('https://google.com', { shell: false })
Expand Down

0 comments on commit 1bec1e9

Please sign in to comment.