test('clinic flame -- node - bad status code', function (t) { // collect data cli({ relayStderr: false }, [ 'clinic', 'flame', '--no-open', '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('subprocess error, code: 1')) t.end() }) })
test('Before all', function (t) { t.plan(1) server = new FakeUploadServer() server.listen(function () { t.ok(server) }) })
test('clinic --help', function (t) { cli({}, ['clinic', '--help'], function (err, stdout) { t.ifError(err) t.ok(/Clinic[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic flame --on-port', function (t) { cli({ relayStderr: false }, [ 'clinic', 'flame', '--no-open', '--on-port', 'autocannon localhost:$PORT -d 2', '--', 'node', path.join(__dirname, 'server.js') ], function (err, stdout, stderr) { t.ifError(err) t.ok(stderr.indexOf('Running 2s test @ http://localhost:') > -1) t.strictEqual(stdout.split('\n')[0], 'Analysing data') t.end() }) })
test('clinic ask -h', function (t) { cli({}, ['clinic', 'ask', '-h'], function (err, stdout) { t.plan(2) t.ifError(err) t.ok(/Clinic.js Ask[^\w ]/.test(stdout.split('\n')[1])) }) })
test('clinic bubbleprof - should error early if non-node script', function (t) { cli({}, ['clinic', 'bubbleprof', '--', 'sh', 'wrapper.sh'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js BubbleProf[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic bubbleprof - should accept full path to node.js', function (t) { cli({}, ['clinic', 'bubbleprof', '--no-open', '--', process.execPath, '-e', 'setTimeout(() => {}, 10)'], function (err, stdout) { t.ifError(err) t.ok(/Generated HTML file is (.*?)\.clinic[/\\](\d+).clinic-bubbleprof/.test(stdout)) t.end() }) })
test('clinic bubbleprof --collect-only - missing data', function (t) { const arg = 'missing.clinic-bubbleprof' cli({ relayStderr: false }, [ 'clinic', 'bubbleprof', '--visualize-only', arg ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.strictEqual(stdout, '') t.ok(stderr.includes(`Unknown argument "${arg}". Pattern: {pid}.clinic-{command}`)) t.end() }) })
test('clinic upload --help', function (t) { cli({}, ['clinic', 'upload', '--help'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js Upload[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic bubbleprof --help', function (t) { cli({}, ['clinic', 'bubbleprof', '--help'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js BubbleProf[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic bubbleprof --collect-only - should error early if non-node script', function (t) { cli({}, ['clinic', 'bubbleprof', '--collect-only', '--', 'sh', 'wrapper.sh'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js BubbleProf[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic doctor', function (t) { cli({}, ['clinic', 'doctor'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js Doctor[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic doctor --collect-only - should error early if non-node script', function (t) { cli({}, ['clinic', 'doctor', '--collect-only', '--', 'sh', 'wrapper.sh'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js Doctor[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic flame - should error early if non-node script', function (t) { cli({}, ['clinic', 'flame', '--', 'sh', 'wrapper.sh'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js Flame[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })