mirror of
https://github.com/clinicjs/node-clinic.git
synced 2026-01-25 16:43:42 +00:00
Improve description with a note how to generate the output (#44)
* Improve description with a note how to generate the output This also adds the debug mode to the documentation.
This commit is contained in:
parent
ac737c1c81
commit
be6c77ad4d
@ -105,6 +105,7 @@ clinic upload --help
|
||||
```
|
||||
-h | --help Display Help
|
||||
-v | --version Display Version
|
||||
--debug Do not minify generated files
|
||||
```
|
||||
|
||||
## Programmable Interfaces
|
||||
|
||||
31
bin.js
31
bin.js
@ -88,7 +88,8 @@ const result = commist()
|
||||
'help',
|
||||
'version',
|
||||
'collect-only',
|
||||
'open'
|
||||
'open',
|
||||
'debug'
|
||||
],
|
||||
string: [
|
||||
'visualize-only',
|
||||
@ -97,7 +98,8 @@ const result = commist()
|
||||
],
|
||||
default: {
|
||||
'sample-interval': '10',
|
||||
'open': true
|
||||
'open': true,
|
||||
'debug': false
|
||||
},
|
||||
'--': true
|
||||
})
|
||||
@ -124,13 +126,15 @@ const result = commist()
|
||||
'help',
|
||||
'version',
|
||||
'collect-only',
|
||||
'open'
|
||||
'open',
|
||||
'debug'
|
||||
],
|
||||
string: [
|
||||
'visualize-only'
|
||||
],
|
||||
default: {
|
||||
'open': true
|
||||
open: true,
|
||||
debug: false
|
||||
},
|
||||
'--': true
|
||||
})
|
||||
@ -157,13 +161,15 @@ const result = commist()
|
||||
'help',
|
||||
'version',
|
||||
'collect-only',
|
||||
'open'
|
||||
'open',
|
||||
'debug'
|
||||
],
|
||||
string: [
|
||||
'visualize-only'
|
||||
],
|
||||
default: {
|
||||
'open': true
|
||||
open: true,
|
||||
debug: false
|
||||
},
|
||||
'--': true
|
||||
})
|
||||
@ -208,9 +214,18 @@ if (result !== null) {
|
||||
function runTool (args, Tool, version) {
|
||||
const onPort = args['on-port']
|
||||
|
||||
if (!onPort && !args['visualize-only']) {
|
||||
if (args['collect-only']) {
|
||||
console.log('To stop data collection press: Ctrl + C')
|
||||
} else {
|
||||
console.log('To generate the report press: Ctrl + C')
|
||||
}
|
||||
}
|
||||
|
||||
const tool = new Tool({
|
||||
sampleInterval: parseInt(args['sample-interval'], 10),
|
||||
detectPort: !!onPort
|
||||
detectPort: !!onPort,
|
||||
debug: args.debug
|
||||
})
|
||||
|
||||
/* istanbul ignore next */
|
||||
@ -227,7 +242,7 @@ function runTool (args, Tool, version) {
|
||||
if (args['collect-only']) {
|
||||
tool.collect(args['--'], function (err, filename) {
|
||||
if (err) throw err
|
||||
console.log(`output file is ${filename}`)
|
||||
console.log(`Output file is ${filename}`)
|
||||
})
|
||||
} else if (args['visualize-only']) {
|
||||
viz(args['visualize-only'], function (err) {
|
||||
|
||||
@ -28,7 +28,7 @@ test('clinic flame --collect-only - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('subprocess error, code: 1'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -39,7 +39,7 @@ test('clinic flame -- node - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('subprocess error, code: 1'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -36,7 +36,7 @@ test('clinic flame --collect-only - missing data', function (t) {
|
||||
'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.strictEqual(stdout, 'To generate the report press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('Invalid data path provided'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -7,11 +7,11 @@ const cli = require('./cli.js')
|
||||
|
||||
test('clinic bubbleprof --collect-only - no issues', function (t) {
|
||||
cli({}, [
|
||||
'clinic', 'bubbleprof', '--collect-only',
|
||||
'clinic', 'bubbleprof', '--collect-only', '--debug',
|
||||
'--', 'node', '-e', 'setTimeout(() => {}, 100)'
|
||||
], function (err, stdout, stderr, tempdir) {
|
||||
t.ifError(err)
|
||||
t.ok(/output file is (\d+).clinic-bubbleprof/.test(stdout))
|
||||
t.ok(/Output file is (\d+).clinic-bubbleprof/.test(stdout))
|
||||
|
||||
const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1]
|
||||
fs.access(path.resolve(tempdir, dirname), function (err) {
|
||||
@ -31,7 +31,7 @@ test('clinic bubbleprof --collect-only - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To stop data collection press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('process exited with exit code 1'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -15,8 +15,8 @@ test('clinic bubbleprof -- node - no issues', function (t) {
|
||||
t.ifError(err)
|
||||
const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1]
|
||||
|
||||
t.strictEqual(stdout.split('\n')[0], 'Analysing data')
|
||||
t.ok(stdout.split('\n')[1], `generated HTML file is ${dirname}.html`)
|
||||
t.strictEqual(stdout.split('\n')[1], 'Analysing data')
|
||||
t.strictEqual(stdout.split('\n')[2], `Generated HTML file is ${dirname}.html`)
|
||||
|
||||
// check that files exists
|
||||
async.parallel({
|
||||
@ -40,7 +40,7 @@ test('clinic bubbleprof -- node - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('process exited with exit code 1'))
|
||||
t.end()
|
||||
})
|
||||
@ -62,7 +62,7 @@ test('clinic bubbleprof -- node - visualization error', function (t) {
|
||||
`
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, 'Analysing data\n')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\nAnalysing data\n')
|
||||
t.ok(stderr.includes('ENOENT: no such file or directory'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -12,7 +12,7 @@ test('clinic bubbleprof --collect-only - no issues', function (t) {
|
||||
'--', 'node', '-e', 'setTimeout(() => {}, 100)'
|
||||
], function (err, stdout, stderr, tempdir) {
|
||||
t.ifError(err)
|
||||
t.ok(/output file is (\d+).clinic-bubbleprof/.test(stdout))
|
||||
t.ok(/Output file is (\d+).clinic-bubbleprof/.test(stdout))
|
||||
const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1]
|
||||
const dirpath = path.resolve(tempdir, dirname)
|
||||
|
||||
@ -21,7 +21,12 @@ test('clinic bubbleprof --collect-only - no issues', function (t) {
|
||||
'clinic', 'bubbleprof', '--visualize-only', dirpath
|
||||
], function (err, stdout) {
|
||||
t.ifError(err)
|
||||
t.strictEqual(stdout, `Generated HTML file is ${dirpath}.html\nYou can use this command to upload it:\nclinic upload ${dirpath}\n`)
|
||||
t.strictEqual(
|
||||
stdout,
|
||||
`Generated HTML file is ${dirpath}.html
|
||||
You can use this command to upload it:
|
||||
clinic upload ${dirpath}
|
||||
`)
|
||||
|
||||
// check that HTML file exists
|
||||
fs.access(dirpath + '.html', function (err) {
|
||||
|
||||
@ -11,7 +11,7 @@ test('clinic doctor --collect-only - no issues', function (t) {
|
||||
'--', 'node', '-e', 'setTimeout(() => {}, 100)'
|
||||
], function (err, stdout, stderr, tempdir) {
|
||||
t.ifError(err)
|
||||
t.ok(/output file is (\d+).clinic-doctor/.test(stdout))
|
||||
t.ok(/Output file is (\d+).clinic-doctor/.test(stdout))
|
||||
|
||||
const dirname = stdout.match(/(\d+.clinic-doctor)/)[1]
|
||||
fs.access(path.resolve(tempdir, dirname), function (err) {
|
||||
@ -31,7 +31,7 @@ test('clinic doctor --collect-only - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To stop data collection press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('process exited with exit code 1'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -15,8 +15,8 @@ test('clinic doctor -- node - no issues', function (t) {
|
||||
t.ifError(err)
|
||||
const dirname = stdout.match(/(\d+.clinic-doctor)/)[1]
|
||||
|
||||
t.strictEqual(stdout.split('\n')[0], 'Analysing data')
|
||||
t.ok(stdout.split('\n')[1], `generated HTML file is ${dirname}.html`)
|
||||
t.strictEqual(stdout.split('\n')[1], 'Analysing data')
|
||||
t.strictEqual(stdout.split('\n')[2], `Generated HTML file is ${dirname}.html`)
|
||||
|
||||
// check that files exists
|
||||
async.parallel({
|
||||
@ -40,7 +40,7 @@ test('clinic doctor -- node - bad status code', function (t) {
|
||||
'--', 'node', '-e', 'process.exit(1)'
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, '')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n')
|
||||
t.ok(stderr.includes('process exited with exit code 1'))
|
||||
t.end()
|
||||
})
|
||||
@ -62,7 +62,7 @@ test('clinic doctor -- node - visualization error', function (t) {
|
||||
`
|
||||
], function (err, stdout, stderr) {
|
||||
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
|
||||
t.strictEqual(stdout, 'Analysing data\n')
|
||||
t.strictEqual(stdout, 'To generate the report press: Ctrl + C\nAnalysing data\n')
|
||||
t.ok(stderr.includes('ENOENT: no such file or directory'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
@ -12,7 +12,7 @@ test('clinic doctor --visualize-only - no issues', function (t) {
|
||||
'--', 'node', '-e', 'setTimeout(() => {}, 100)'
|
||||
], function (err, stdout, stderr, tempdir) {
|
||||
t.ifError(err)
|
||||
t.ok(/output file is (\d+).clinic-doctor/.test(stdout))
|
||||
t.ok(/Output file is (\d+).clinic-doctor/.test(stdout))
|
||||
const dirname = stdout.match(/(\d+.clinic-doctor)/)[1]
|
||||
const dirpath = path.resolve(tempdir, dirname)
|
||||
|
||||
@ -21,7 +21,12 @@ test('clinic doctor --visualize-only - no issues', function (t) {
|
||||
'clinic', 'doctor', '--visualize-only', dirpath
|
||||
], function (err, stdout) {
|
||||
t.ifError(err)
|
||||
t.strictEqual(stdout, `Generated HTML file is ${dirpath}.html\nYou can use this command to upload it:\nclinic upload ${dirpath}\n`)
|
||||
t.strictEqual(
|
||||
stdout,
|
||||
`Generated HTML file is ${dirpath}.html
|
||||
You can use this command to upload it:
|
||||
clinic upload ${dirpath}
|
||||
`)
|
||||
|
||||
// check that HTML file exists
|
||||
fs.access(dirpath + '.html', function (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user