Skip to content

Commit

Permalink
chore: test fix exec.node.js tests
Browse files Browse the repository at this point in the history
It was not using the dirty-chai so the expect.to.not.exist was failing. It was also trying to trap SIG* with bin/sh which does not recognize those signals (dropping the SIG prefix works in sh).

This SIG* trapping was what I think was making CI tests fail so I enabled testing in CI again.
  • Loading branch information
wraithgar authored and daviddias committed Jun 4, 2018
1 parent e0b8227 commit fd7a590
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions test/exec.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const isrunning = require('is-running')
const cp = require('child_process')
const path = require('path')
Expand All @@ -18,12 +21,12 @@ function token () {
return Math.random().toString().substr(2)
}

function psExpect (pid, expect, grace, callback) {
function psExpect (pid, shouldBeRunning, grace, callback) {
setTimeout(() => {
const actual = isrunning(pid)

if (actual !== expect && grace > 0) {
return psExpect(pid, expect, --grace, callback)
if (actual !== shouldBeRunning && grace > 0) {
return psExpect(pid, shouldBeRunning, --grace, callback)
}

callback(null, actual)
Expand Down Expand Up @@ -66,7 +69,7 @@ function makeCheck (n, done) {
describe('exec', () => {
// TODO: skip on windows for now
// TODO: running under coverage messes up the process hierarchies
if (isWindows || process.env['COVERAGE']) {
if (isWindows || process.env.COVERAGE) {
return
}

Expand Down Expand Up @@ -101,11 +104,6 @@ describe('exec', () => {
})
})

// Travis and CircleCI don't like the usage of SIGHUP
if (process.env.CI) {
return
}

it('SIGKILL kills survivor', (done) => {
const check = makeCheck(2, done)

Expand Down
4 changes: 2 additions & 2 deletions test/survivor
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
trap "echo 'you cannot kill me!'" SIGHUP SIGINT SIGTERM SIGQUIT SIGPIPE
while true; do sleep 1; done
trap "echo 'you cannot kill me!'" HUP INT TERM QUIT PIPE
while true; do sleep 1; done

0 comments on commit fd7a590

Please sign in to comment.