<commit_before>import spawn from '../src/spawn'
import {childPrinted} from 'async-child-process'
import {expect} from 'chai'

describe('killOnExit', () => {
  it('kills child when parent process exits', async function () {
    this.timeout(20000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    // wait for parent to exit
    await new Promise(resolve => setTimeout(resolve, 2000))
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('kills child when parent process is killed with SIGINT', async function () {
    this.timeout(20000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    proc.kill('SIGINT')
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('kills child when parent process is killed with SIGTERM', async function () {
    this.timeout(20000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    proc.kill('SIGTERM')
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('works when child process exits by itself', async function () {
    this.timeout(20000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent2')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    // wait for parent to exit
    await new Promise(resolve => setTimeout(resolve, 2000))
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
})
<commit_msg>make ridiculously long timeouts for node 4<commit_after>import spawn from '../src/spawn'
import {childPrinted} from 'async-child-process'
import {expect} from 'chai'

describe('killOnExit', () => {
  it('kills child when parent process exits', async function () {
    this.timeout(60000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    // wait for parent to exit
    await new Promise(resolve => setTimeout(resolve, 2000))
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('kills child when parent process is killed with SIGINT', async function () {
    this.timeout(60000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    proc.kill('SIGINT')
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('kills child when parent process is killed with SIGTERM', async function () {
    this.timeout(60000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    proc.kill('SIGTERM')
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
  it('works when child process exits by itself', async function () {
    this.timeout(60000)
    const proc = spawn('babel-node', [require.resolve('./util/killOnExitParent2')], {silent: true})
    const parentOutput = await childPrinted(proc, /parent pid: \d+/)
    const parentPid = parentOutput.substring("parent pid: ".length)
    const childOutput = await childPrinted(proc, /child pid: \d+/)
    const childPid = childOutput.substring("child pid: ".length)
    // wait for parent to exit
    await new Promise(resolve => setTimeout(resolve, 2000))
    expect(() => process.kill(parentPid, 0)).to.throw
    expect(() => process.kill(childPid, 0)).to.throw
  })
})

{'fraction_non_alphanumeric': 0.1543243737429146, 'fraction_numerical': 0.013713658804168952, 'mean_word_length': 4.04147465437788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7184302', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1650, 'n_words': 450}