Skip to content

Commit 88c2279

Browse files
willmsCmschileemilyrohrboughflotwig
authored
fix: spawn child process with process.env in macOS arm64 (#25753)
Co-authored-by: Matt Schile <mschile@cypress.io> Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com> Co-authored-by: Zach Bloomquist <github@chary.us>
1 parent a11e266 commit 88c2279

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _Released 02/14/2023 (PENDING)_
1515
- Fixed an issue with the Cloud project selection modal not showing the correct prompts. Fixes [#25520](https://github.com/cypress-io/cypress/issues/25520).
1616
- Fixed an issue in middleware where error-handling code could itself generate an error and fail to report the original issue. Fixes [#22825](https://github.com/cypress-io/cypress/issues/22825).
1717
- Fixed an issue that could cause the Debug page to display a different number of specs for in-progress runs than shown in Cypress Cloud. Fixes [#25647](https://github.com/cypress-io/cypress/issues/25647).
18+
- Fixed an issue introduced in Cypress 12.3.0 where custom browsers that relied on process environment variables were not found on macOS arm64 architectures. Fixed in [#25753](https://github.com/cypress-io/cypress/pull/25753).
1819

1920
**Misc:**
2021

packages/launcher/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const utils = {
4242
let stdout = ''
4343
let stderr = ''
4444

45-
const proc = utils.spawnWithArch(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] })
45+
const proc = utils.spawnWithArch(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'], env: process.env })
4646

4747
const finish = () => {
4848
proc.kill()

packages/launcher/test/unit/darwin_spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('darwin browser detection', () => {
9090

9191
context('forces correct architecture', () => {
9292
function stubForArch (arch: 'arm64' | 'x64') {
93+
sinon.stub(process, 'env').value({ env2: 'false', env3: 'true' })
9394
sinon.stub(os, 'arch').returns(arch)
9495
sinon.stub(os, 'platform').returns('darwin')
9596
getOutput.restore()
@@ -111,6 +112,8 @@ describe('darwin browser detection', () => {
111112
expect(args[1]).to.deep.eq([knownBrowsers[0].binary, '--version'])
112113
expect(args[2].env).to.deep.include({
113114
ARCHPREFERENCE: 'arm64,x86_64',
115+
env2: 'false',
116+
env3: 'true',
114117
})
115118
})
116119

@@ -125,15 +128,18 @@ describe('darwin browser detection', () => {
125128

126129
expect(args[0]).to.eq(knownBrowsers[0].binary)
127130
expect(args[1]).to.deep.eq(['--version'])
128-
expect(args[2].env).to.not.exist
131+
expect(args[2].env).to.deep.include({
132+
env2: 'false',
133+
env3: 'true',
134+
})
129135
})
130136
})
131137

132138
context('in browser launching', () => {
133139
it('uses arch and ARCHPREFERENCE on arm64', async () => {
134140
const cpSpawn = stubForArch('arm64')
135141

136-
await launch({ path: 'chrome' } as unknown as FoundBrowser, 'url', 123, ['arg1'], { env1: 'true' })
142+
await launch({ path: 'chrome' } as unknown as FoundBrowser, 'url', 123, ['arg1'], { env1: 'true', env2: 'true' })
137143

138144
const { args } = cpSpawn.getCall(0)
139145

@@ -142,20 +148,24 @@ describe('darwin browser detection', () => {
142148
expect(args[2].env).to.deep.include({
143149
ARCHPREFERENCE: 'arm64,x86_64',
144150
env1: 'true',
151+
env2: 'false',
152+
env3: 'true',
145153
})
146154
})
147155

148156
it('does not use `arch` on x64', async () => {
149157
const cpSpawn = stubForArch('x64')
150158

151-
await launch({ path: 'chrome' } as unknown as FoundBrowser, 'url', 123, ['arg1'], { env1: 'true' })
159+
await launch({ path: 'chrome' } as unknown as FoundBrowser, 'url', 123, ['arg1'], { env1: 'true', env2: 'true' })
152160

153161
const { args } = cpSpawn.getCall(0)
154162

155163
expect(args[0]).to.eq('chrome')
156164
expect(args[1]).to.deep.eq(['url', 'arg1'])
157165
expect(args[2].env).to.deep.include({
158166
env1: 'true',
167+
env2: 'false',
168+
env3: 'true',
159169
})
160170

161171
expect(args[2].env).to.not.have.property('ARCHPREFERENCE')

0 commit comments

Comments
 (0)