Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const extensions = {
return
}

res = spawnSync('xcode-select', ['-p'])
res = spawnSync('xcode-select', ['-p'], { encoding: 'utf8' })
if (res.status !== 0) {
console.error('Failed to get Xcode path')
return
}

const simulatorPath = path.join(res.stdout, 'Applications', 'Simulator.app')
const simulatorPath = path.join(res.stdout.trim(), 'Applications', 'Simulator.app')
return spawnSync('open', ['-a', simulatorPath])
} else {
// Xcode 8 or older
Expand Down
3 changes: 2 additions & 1 deletion test/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ test('start', async (ctx) => {
spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: 'Xcode 13.2.1' }), 0) // xcodebuild -version
spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: JSON.stringify(testJson) }), 1) // xcrun simctl list -j
spawnMock.mock.mockImplementationOnce(() => ({ status: 0 }), 2) // xcrun simctl boot <deviceid>
spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: '/Applications/Xcode.app/Contents/Developer' }), 3) // xcode-select -p
spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: '/Applications/Xcode.app/Contents/Developer\n' }), 3) // xcode-select -p
spawnMock.mock.mockImplementationOnce(() => ({ status: 0 }), 4) // open -a XCODEPATH/Applications/Simulator.app

const retObj = SimCtlExtensions.start(deviceId)
t.assert.deepEqual(retObj, { status: 0 })
t.assert.equal(console.error.mock.calls.length, 0)
t.assert.deepEqual(spawnMock.mock.calls[4].arguments[1], ['-a', '/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'])
})

await ctx.test('successful start (Xcode < 9)', (t) => {
Expand Down