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('clinic ask', function (t) { cli({}, ['clinic', 'ask'], function (err, stdout) { t.plan(2) t.strictDeepEqual(err, new Error('process exited with exit code 1')) 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 flame --collect-only - missing data', function (t) { cli({ relayStderr: false }, [ 'clinic', 'flame', '--visualize-only', 'missing.flamegraph' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.strictEqual(stdout, '') t.match(stderr, /Unknown argument "missing\.flamegraph"\. Pattern: {pid}\.clinic-{command}/) 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 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() }) })
test('clinic', function (t) { cli({}, ['clinic'], function (err, stdout) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) t.ok(/Clinic[^\w ]/.test(stdout.split('\n')[1])) t.end() }) })
test('clinic doctor - should error early if non-node script', function (t) { cli({}, ['clinic', 'doctor', '--', '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 --collect-only - bad status code', function (t) { cli({ relayStderr: false }, [ 'clinic', 'flame', '--collect-only', '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { 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('subprocess error, code: 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 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() }) })
test('clinic flame --visualize-only - missing data', function (t) { const arg = 'missing.clinic-flame' cli({ relayStderr: false }, [ 'clinic', 'flame', '--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() }) })