Skip to content

Commit

Permalink
fix: make kill() work on Linux in test
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Prodromou <[email protected]>
  • Loading branch information
Evan Prodromou committed Sep 21, 2023
1 parent 81e1697 commit c03825b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,7 @@ const cleanup = () => {
process.exit(0)
})
})
};
}

// Listen for SIGINT (Ctrl+C) and SIGTERM (Termination) signals

Expand All @@ -2656,7 +2656,7 @@ process.on('SIGINT', () => {
})

process.on('SIGTERM', () => {
logger.info(`Closing app on SIGINT on ${PORT}`)
logger.info(`Closing app on SIGTERM on ${PORT}`)
cleanup()
})

Expand Down
10 changes: 5 additions & 5 deletions index.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, before, after, it } from 'node:test'
import { exec } from 'node:child_process'
import { spawn } from 'node:child_process'
import assert from 'node:assert'
import querystring from 'node:querystring'
import { inspect } from 'node:util'
Expand All @@ -14,7 +14,7 @@ const delay = (t) => new Promise((resolve) => setTimeout(resolve, t))

const startServer = (port = 3000) => {
return new Promise((resolve, reject) => {
const server = exec('node index.mjs', { env: { ...process.env, OPP_PORT: port } })
const server = spawn('node', ['index.mjs'], { env: { ...process.env, OPP_PORT: port } })
server.on('error', reject)
server.stdout.on('data', (data) => {
if (data.toString().includes('Listening')) {
Expand Down Expand Up @@ -237,7 +237,7 @@ const cantUpdate = async (actor, token, object, properties) => {
})
}

describe('onepage.pub', () => {
describe('onepage.pub', { only: true }, () => {
let child = null
let remote = null

Expand All @@ -247,8 +247,8 @@ describe('onepage.pub', () => {
})

after(() => {
child.kill()
remote.kill()
child.kill('SIGTERM')
remote.kill('SIGTERM')
})

describe('Root object', () => {
Expand Down

0 comments on commit c03825b

Please sign in to comment.