-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add v8 snapshot usage to cypress in cypress testing #24860
Changes from 28 commits
f03253c
65580d9
6684f14
e2d06d1
67d7366
a45ca79
a5388d9
92c21ad
d082194
f24e168
33cbd0c
7894213
4a12e7d
ff9387c
d4ef5b4
dd6d5d9
51eff1c
c962c42
0652445
b4c119e
737391b
aa5f7af
7d80f64
f4c207f
0873220
5179d50
ce86292
2bf7b8a
d8f5dcf
40ec8ef
1ff5927
ea40564
0d9e3cb
8bab2db
d483d47
9ba8ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Bump this version to force CI to re-create the cache from scratch. | ||
|
||
12-01-22 | ||
12-05-22 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* eslint-disable no-dupe-class-members */ | ||
import { CypressError, getError } from '@packages/errors' | ||
import type { FullConfig, TestingType } from '@packages/types' | ||
import { ChildProcess, fork, ForkOptions } from 'child_process' | ||
import { ChildProcess, fork, ForkOptions, spawn } from 'child_process' | ||
import EventEmitter from 'events' | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
|
@@ -10,6 +10,7 @@ import debugLib from 'debug' | |
import { autoBindDebug, hasTypeScriptInstalled, toPosix } from '../util' | ||
import _ from 'lodash' | ||
import { pathToFileURL } from 'url' | ||
import os from 'os' | ||
|
||
const pkg = require('@packages/root') | ||
const debug = debugLib(`cypress:lifecycle:ProjectConfigIpc`) | ||
|
@@ -21,6 +22,14 @@ const tsNode = toPosix(require.resolve('@packages/server/lib/plugins/child/regis | |
|
||
export type IpcHandler = (ipc: ProjectConfigIpc) => void | ||
|
||
/** | ||
* If running as root on Linux, no-sandbox must be passed or Chrome will not start | ||
*/ | ||
const isSandboxNeeded = () => { | ||
// eslint-disable-next-line no-restricted-properties | ||
return (os.platform() === 'linux') && (process.geteuid && process.geteuid() === 0) | ||
} | ||
|
||
export interface SetupNodeEventsReply { | ||
setupConfig: Cypress.ConfigOptions | null | ||
requires: string[] | ||
|
@@ -310,6 +319,17 @@ export class ProjectConfigIpc extends EventEmitter { | |
debug(`no typescript found, just use regular Node.js`) | ||
} | ||
|
||
if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bit of a shame we need to ship test code to prod :'( This is "the change" that lets v8 snapshots run in cy-in-cy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anyway to verify it now uses snapshots in the tests? How do we know it works (and catch it if stops?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it's unfortunate, but I'm not sure of a clean way to do it otherwise with how everything is structured. And, I like your idea. I added a check to ensure that we fail in cypress in cypress if the snapshot is unavailable. |
||
if (isSandboxNeeded()) { | ||
configProcessArgs.push('--no-sandbox') | ||
} | ||
|
||
return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { | ||
...childOptions, | ||
stdio: ['pipe', 'pipe', 'pipe', 'ipc'], | ||
}) | ||
} | ||
|
||
return fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to match the rest of the repo.