Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct bad propagation of exit signals (#7755)
- Loading branch information
Showing
3 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import '../spec_helper' | ||
import sinon from 'sinon' | ||
import { expect } from 'chai' | ||
import cp, { ChildProcess } from 'child_process' | ||
import { EventEmitter } from 'events' | ||
import * as nodeOptions from '../../lib/util/node_options' | ||
import mockedEnv from 'mocked-env' | ||
|
||
describe('NODE_OPTIONS lib', function () { | ||
context('.forkWithCorrectOptions', function () { | ||
let fakeProc: EventEmitter | ||
let restoreEnv | ||
|
||
beforeEach(() => { | ||
restoreEnv = mockedEnv({ | ||
NODE_OPTIONS: '', | ||
ORIGINAL_NODE_OPTIONS: '', | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
restoreEnv() | ||
}) | ||
|
||
it('modifies NODE_OPTIONS', function () { | ||
process.env.NODE_OPTIONS = 'foo' | ||
expect(process.env.NODE_OPTIONS).to.eq('foo') | ||
sinon.stub(cp, 'spawn').callsFake(() => { | ||
expect(process.env).to.include({ | ||
NODE_OPTIONS: `${nodeOptions.NODE_OPTIONS} foo`, | ||
ORIGINAL_NODE_OPTIONS: 'foo', | ||
}) | ||
|
||
return null as ChildProcess // types | ||
}) | ||
}) | ||
|
||
context('when exiting', function () { | ||
beforeEach(() => { | ||
fakeProc = new EventEmitter() | ||
|
||
sinon.stub(cp, 'spawn') | ||
.withArgs(process.execPath, sinon.match.any, { stdio: 'inherit' }) | ||
.returns(fakeProc as ChildProcess) | ||
|
||
sinon.stub(process, 'exit') | ||
}) | ||
|
||
it('propagates exit codes correctly', function () { | ||
nodeOptions.forkWithCorrectOptions() | ||
fakeProc.emit('exit', 123) | ||
expect(process.exit).to.be.calledWith(123) | ||
}) | ||
|
||
// @see https://github.com/cypress-io/cypress/issues/7722 | ||
it('propagates signals via a non-zero exit code', function () { | ||
nodeOptions.forkWithCorrectOptions() | ||
fakeProc.emit('exit', null, 'SIGKILL') | ||
expect(process.exit).to.be.calledWith(1) | ||
}) | ||
}) | ||
}) | ||
}) |
This comment was marked as off-topic.
Sorry, something went wrong.
bf752f1
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.
AppVeyor has built the
win32 ia32
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.Instructions are included below, depending on the shell you are using.
In Command Prompt (
cmd.exe
):In PowerShell:
In Git Bash:
Using
cross-env
:If the above commands do not work for you, you can also try using
cross-env
:bf752f1
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.
AppVeyor has built the
win32 x64
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.Instructions are included below, depending on the shell you are using.
In Command Prompt (
cmd.exe
):In PowerShell:
In Git Bash:
Using
cross-env
:If the above commands do not work for you, you can also try using
cross-env
:bf752f1
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.
Circle has built the
darwin x64
version of the Test Runner.You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.
You will need to use custom
CYPRESS_INSTALL_BINARY
url and install Cypress using an url instead of the version.