-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: fix prof polyfill readline #18641
Changes from 3 commits
33f4a51
45730d5
2610183
05b0391
3684bc0
a43951e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,11 @@ Platform check for Windows. | |
|
||
Platform check for Windows 32-bit on Windows 64-bit. | ||
|
||
### isSymbolAvailable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a more descriptive name than this please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad,it should be |
||
* [<Boolean>] | ||
|
||
Platform check for if symbol available. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, can you provide a more in depth description. |
||
|
||
### leakedGlobals() | ||
* return [<Array>] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
tmpdir.refresh(); | ||
|
||
if (!common.enoughTestCpu) | ||
common.skip('test is CPU-intensive'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: would you be so kind and use a capital letter as first character? :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the node test,the first character in skip message is always lower case. |
||
|
||
if (common.isSymbolAvailable) { | ||
common.skip('C++ symbols are not mapped for this os.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure whether the linter ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Operating system should be upper cased as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the advice.It should be upper cased. |
||
} | ||
|
||
//This test will produce a broken profile log. | ||
//ensure prof-polyfill not stuck in infinite loop | ||
//and success process | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: please use a space at the beginning of each line in a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the advice.It should have a space at the beginning of each line. |
||
|
||
|
||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const LOG_FILE = path.join(tmpdir.path, 'tick-processor.log'); | ||
const RETRY_TIMEOUT = 150; | ||
const BROKEN_PART = 'tick,'; | ||
const WARN_REG_EXP = /\(node:\d+\) \[BROKEN_PROFILE_FILE\] Warning: profile file is broken[\r\n]+".*tick," at the file end is broken/; | ||
|
||
const code = `function f() { | ||
this.ts = Date.now(); | ||
setImmediate(function() { new f(); }); | ||
}; | ||
f();`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we have the unwritten rule not to use multi line template strings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the advice.I will split it to two lines. |
||
|
||
const proc = cp.spawn(process.execPath, [ | ||
'--no_logfile_per_isolate', | ||
'--logfile=-', | ||
'--prof', | ||
'-pe', code | ||
], { | ||
stdio: ['ignore', 'pipe', 'inherit'] | ||
}); | ||
|
||
let ticks = ''; | ||
proc.stdout.on('data', (chunk) => ticks += chunk); | ||
|
||
|
||
function runPolyfill(content) { | ||
proc.kill(); | ||
content += BROKEN_PART; | ||
fs.writeFileSync(LOG_FILE, content); | ||
const child = cp.spawnSync( | ||
`${process.execPath}`, | ||
[ | ||
'--prof-process', LOG_FILE | ||
]); | ||
assert(WARN_REG_EXP.test(child.stderr.toString())); | ||
assert.strictEqual(child.status, 0, 'broken file should success too'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally would like to stick to the default message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default message will be removed. |
||
} | ||
|
||
setTimeout(() => runPolyfill(ticks), RETRY_TIMEOUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: you might just add the filename of the broken file? And please use a capital letter as first character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the advice.Add the filename is better.