UNPKG

809 BJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const { spawn } = require('child_process')
5const endpoint = require('endpoint')
6const rimraf = require('rimraf')
7const ClinicDoctor = require('../index.js')
8
9test('collect command stops when cluster is used', function (t) {
10 t.plan(3)
11
12 const doctor = new ClinicDoctor({})
13 doctor.collect([process.execPath, '-e', 'require("cluster")'], (err, result) => {
14 t.ifError(err, 'should not crash when cluster is required but not used')
15 rimraf.sync(result)
16 })
17
18 const proc = spawn(process.execPath, [
19 require.resolve('./cmd-no-cluster.script.js')
20 ], { stdio: 'pipe' })
21
22 proc.stderr.pipe(endpoint((err, buf) => {
23 t.ifError(err)
24 t.ok(buf.toString('utf8').includes('does not support clustering'), 'should crash once cluster is used')
25 }))
26})