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:
Ruben Bridgewater 2018-08-27 15:49:37 +02:00 committed by GitHub
parent ac737c1c81
commit be6c77ad4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 54 additions and 28 deletions

View File

@ -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
View File

@ -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) {

View File

@ -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()
})

View File

@ -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()
})

View File

@ -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()
})

View File

@ -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()
})

View File

@ -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()
})

View File

@ -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) {

View File

@ -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()
})

View File

@ -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()
})

View File

@ -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) {