fix few problems found

This commit is contained in:
Emily Rohrbough
2026-02-24 23:42:18 -06:00
parent 65097e03dc
commit 15074913bd
2 changed files with 41 additions and 2 deletions
+6 -1
View File
@@ -95,14 +95,19 @@ const runSmokeTest = (binaryDir: string, options: any): any => {
const stdioOptions = _.extend({}, {
env: {
...process.env,
...options.env,
FORCE_COLOR: '0',
},
// execa defaults to extending process.env. We pass a fully-shaped env object
// and need to prevent leaked parent vars (like ELECTRON_RUN_AS_NODE) from
// being reintroduced after sanitization.
extendEnv: false,
timeout: options.smokeTestTimeout,
})
// Sandboxed shells can leak ELECTRON_RUN_AS_NODE=1 into child processes.
// Verify must run Electron in normal mode so --smoke-test/--ping are handled by Cypress.
if (!process.env.CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE) {
if (!stdioOptions.env.CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE) {
delete stdioOptions.env.ELECTRON_RUN_AS_NODE
}
+35 -1
View File
@@ -407,7 +407,7 @@ describe('lib/tasks/verify', () => {
expect(util.exec).toHaveBeenCalledWith(
executablePath,
['--no-sandbox', '--smoke-test', '--ping=222'],
expect.objectContaining({ env: expect.objectContaining({ FORCE_COLOR: '0' }) }),
expect.objectContaining({ env: expect.objectContaining({ FORCE_COLOR: '0' }), extendEnv: false }),
)
})
@@ -431,10 +431,44 @@ describe('lib/tasks/verify', () => {
executablePath,
['--no-sandbox', '--smoke-test', '--ping=222'],
expect.objectContaining({
extendEnv: false,
env: expect.not.objectContaining({ ELECTRON_RUN_AS_NODE: expect.anything() }),
}),
)
})
it('keeps ELECTRON_RUN_AS_NODE when explicitly forced in child env options', async () => {
createfs({
alreadyVerified: false,
executable: mockfs.file({ mode: 0o777 }),
packageVersion,
})
vi.mocked(util.exec).mockResolvedValue({
stdout: '222',
stderr: '',
} as any)
await start({
listrRenderer: 'silent',
env: {
ELECTRON_RUN_AS_NODE: '1',
CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE: '1',
},
})
expect(util.exec).toHaveBeenCalledWith(
executablePath,
['--no-sandbox', '--smoke-test', '--ping=222'],
expect.objectContaining({
extendEnv: false,
env: expect.objectContaining({
ELECTRON_RUN_AS_NODE: '1',
CYPRESS_INTERNAL_FORCE_ELECTRON_RUN_AS_NODE: '1',
}),
}),
)
})
})
describe('with force: true', () => {