test('clinic doctor --collect-only - bad status code', function (t) { cli({ relayStderr: false }, [ 'clinic', 'doctor', '--collect-only', '--dest', './foo', '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr, tempdir) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.strictEqual(stdout, 'To stop data collection press: Ctrl + C\n') t.ok(stderr.includes('process exited with exit code 1')) t.end() }) })
test('clinic bubbleprof -v', function (t) { cli({}, ['clinic', 'bubbleprof', '-v'], function (err, stdout) { t.ifError(err) t.strictEqual( stdout, `v${require('@nearform/bubbleprof/package.json').version}\n` ) t.end() }) })
test('clinic flame - should accept full path to node.js', function (t) { cli({}, ['clinic', 'flame', '--no-open', '--', process.execPath, '-e', 'setTimeout(() => {}, 10)'], function (err, stdout) { t.ifError(err) t.ok(/Generated HTML file is (.*?)\.clinic[/\\](\d+).clinic-flame/.test(stdout)) t.end() }) })
test('clinic doctor --help', function (t) { cli({}, ['clinic', 'doctor', '--help'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js Doctor[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic flame --collect-only - should error early if non-node script', function (t) { cli({}, ['clinic', 'flame', '--collect-only', '--', '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() }) })
test('clinic --version', function (t) { cli({}, ['clinic', '--version'], function (err, stdout) { t.ifError(err) t.strictEqual( stdout, `v${require('../package.json').version}\n` ) t.end() }) })
test('clinic doctor -h', function (t) { cli({}, ['clinic', 'doctor', '-h'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js Doctor[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic doctor -v', function (t) { cli({}, ['clinic', 'doctor', '-v'], function (err, stdout) { t.ifError(err) t.strictEqual( stdout, `v${require('@nearform/doctor/package.json').version}\n` ) t.end() }) })
test('clinic doctor --visualize-only - missing data', function (t) { const arg = 'missing.clinic-doctor' cli({ relayStderr: false }, [ 'clinic', 'doctor', '--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', function (t) { cli({}, ['clinic', 'upload'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic.js Upload[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic bubbleprof -h', function (t) { cli({}, ['clinic', 'bubbleprof', '-h'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js BubbleProf[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic bubbleprof', function (t) { cli({}, ['clinic', 'bubbleprof'], 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 -h', function (t) { cli({}, ['clinic', '-h'], function (err, stdout) { t.ifError(err) t.ok(/Clinic[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic flame --help', function (t) { cli({}, ['clinic', 'flame', '--help'], function (err, stdout) { t.ifError(err) t.ok(/Clinic.js Flame[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic flame', function (t) { cli({}, ['clinic', 'flame'], 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() }) })