-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add stop-delay option * doc: stop-delay option documentation * chore: upgrade minimum v12 version * tests: improve test to stop-delay
- Loading branch information
Showing
12 changed files
with
207 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const url = require('url') | ||
const async = require('async') | ||
const path = require('path') | ||
const test = require('tap').test | ||
const cli = require('./cli.js') | ||
|
||
test('clinic bubbleprof --stop-delay --on-port - no issues', function (t) { | ||
cli({}, [ | ||
'clinic', 'bubbleprof', '--no-open', '--stop-delay', '500', '--on-port', 'node -e "setTimeout(() => {}, 0)"', | ||
'--', 'node', '-e', ` | ||
const http = require('http') | ||
http.createServer((req, res) => res.end('ok')).listen(0) | ||
` | ||
], function (err, stdout, stderr, tempdir) { | ||
t.error(err) | ||
|
||
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-bubbleprof)/)[1] | ||
const fullpath = url.pathToFileURL(fs.realpathSync(path.resolve(tempdir, dirname))) | ||
t.equal(stdout.split('\n')[0], 'Waiting to close the process') | ||
t.equal(stdout.split('\n')[1], 'Analysing data') | ||
t.equal(stdout.split('\n')[2], `Generated HTML file is ${fullpath}.html`) | ||
|
||
// check that files exists | ||
async.parallel({ | ||
sourceData (done) { | ||
fs.access(path.resolve(tempdir, dirname), done) | ||
}, | ||
htmlFile (done) { | ||
fs.access(path.resolve(tempdir, dirname + '.html'), done) | ||
} | ||
}, function (err) { | ||
t.error(err) | ||
t.end() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const url = require('url') | ||
const async = require('async') | ||
const path = require('path') | ||
const test = require('tap').test | ||
const cli = require('./cli.js') | ||
|
||
test('clinic doctor --stop-delay --on-port - no issues', function (t) { | ||
cli({}, [ | ||
'clinic', 'doctor', '--no-open', '--stop-delay', '500', '--on-port', 'node -e "setTimeout(() => {}, 0)"', | ||
'--', 'node', '-e', ` | ||
const http = require('http') | ||
http.createServer((req, res) => res.end('ok')).listen(0) | ||
` | ||
], function (err, stdout, stderr, tempdir) { | ||
t.error(err) | ||
|
||
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-doctor)/)[1] | ||
const fullpath = url.pathToFileURL(fs.realpathSync(path.resolve(tempdir, dirname))) | ||
t.equal(stdout.split('\n')[0], 'Waiting to close the process') | ||
t.equal(stdout.split('\n')[1], 'Analysing data') | ||
t.equal(stdout.split('\n')[2], `Generated HTML file is ${fullpath}.html`) | ||
|
||
// check that files exists | ||
async.parallel({ | ||
sourceData (done) { | ||
fs.access(path.resolve(tempdir, dirname), done) | ||
}, | ||
htmlFile (done) { | ||
fs.access(path.resolve(tempdir, dirname + '.html'), done) | ||
} | ||
}, function (err) { | ||
t.error(err) | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
|
||
test('clinic doctor --stop-delay --on-port - exceeding timeout', function (t) { | ||
const onPortDuration = 500 | ||
setTimeout(() => { | ||
t.pass('timeout should be called before t.fail') | ||
t.end() | ||
process.exit(0) | ||
}, onPortDuration + 500) | ||
cli({}, [ | ||
'clinic', 'doctor', '--no-open', '--stop-delay', '2000', '--on-port', `node -e "setTimeout(() => {}, ${onPortDuration})"`, | ||
'--', 'node', '-e', ` | ||
const http = require('http') | ||
http.createServer((req, res) => res.end('ok')).listen(0) | ||
` | ||
], function () { | ||
t.fail('it should not be called once timeout is reached') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const url = require('url') | ||
const async = require('async') | ||
const path = require('path') | ||
const test = require('tap').test | ||
const cli = require('./cli.js') | ||
|
||
test('clinic flame --stop-delay --on-port - no issues', function (t) { | ||
cli({}, [ | ||
'clinic', 'flame', '--no-open', '--stop-delay', '500', '--on-port', 'node -e "setTimeout(() => {}, 0)"', | ||
'--', 'node', '-e', ` | ||
const http = require('http') | ||
http.createServer((req, res) => res.end('ok')).listen(0) | ||
` | ||
], function (err, stdout, stderr, tempdir) { | ||
t.error(err) | ||
|
||
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-flame)/)[1] | ||
const fullpath = url.pathToFileURL(fs.realpathSync(path.resolve(tempdir, dirname))) | ||
t.equal(stdout.split('\n')[0], 'Waiting to close the process') | ||
t.equal(stdout.split('\n')[1], 'Analysing data') | ||
t.equal(stdout.split('\n')[2], `Generated HTML file is ${fullpath}.html`) | ||
|
||
// check that files exists | ||
async.parallel({ | ||
sourceData (done) { | ||
fs.access(path.resolve(tempdir, dirname), done) | ||
}, | ||
htmlFile (done) { | ||
fs.access(path.resolve(tempdir, dirname + '.html'), done) | ||
} | ||
}, function (err) { | ||
t.error(err) | ||
t.end() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const url = require('url') | ||
const async = require('async') | ||
const path = require('path') | ||
const test = require('tap').test | ||
const cli = require('./cli.js') | ||
|
||
test('clinic heapprofiler --stop-delay --on-port - no issues', function (t) { | ||
cli({}, [ | ||
'clinic', 'heapprofiler', '--no-open', '--stop-delay', '500', '--on-port', 'node -e "setTimeout(() => {}, 0)"', | ||
'--', 'node', '-e', ` | ||
const http = require('http') | ||
http.createServer((req, res) => res.end('ok')).listen(0) | ||
` | ||
], function (err, stdout, stderr, tempdir) { | ||
t.error(err) | ||
|
||
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-heapprofile)/)[1] | ||
const fullpath = url.pathToFileURL(fs.realpathSync(path.resolve(tempdir, dirname))) | ||
t.equal(stdout.split('\n')[0], 'Waiting to close the process') | ||
t.equal(stdout.split('\n')[1], 'Analysing data') | ||
t.equal(stdout.split('\n')[2], `Generated HTML file is ${fullpath}.html`) | ||
|
||
// check that files exists | ||
async.parallel({ | ||
sourceData (done) { | ||
fs.access(path.resolve(tempdir, dirname), done) | ||
}, | ||
htmlFile (done) { | ||
fs.access(path.resolve(tempdir, dirname + '.html'), done) | ||
} | ||
}, function (err) { | ||
t.error(err) | ||
t.end() | ||
}) | ||
}) | ||
}) |