-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
33f4a51
tools: fix prof polyfill readline
killagu 45730d5
test: add common.isSymbolAvailable
killagu 2610183
fix: fix code style
killagu 05b0391
mv common.isSymbolAvailable -> common.isCPPSymbolsNotMapped
killagu 3684bc0
fix c++ -> C++
killagu a43951e
fix code style
killagu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
62 changes: 62 additions & 0 deletions
62
test/tick-processor/test-tick-processor-polyfill-brokenfile.js
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,62 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
tmpdir.refresh(); | ||
|
||
if (!common.enoughTestCpu) | ||
common.skip('test is CPU-intensive'); | ||
|
||
if (common.isCPPSymbolsNotMapped) { | ||
common.skip('C++ symbols are not mapped for this OS.'); | ||
} | ||
|
||
// This test will produce a broken profile log. | ||
// ensure prof-polyfill not stuck in infinite loop | ||
// and success process | ||
|
||
|
||
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/; | ||
const WARN_DETAIL_REG_EXP = /".*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(WARN_DETAIL_REG_EXP.test(child.stderr.toString())); | ||
assert.strictEqual(child.status, 0); | ||
} | ||
|
||
setTimeout(() => runPolyfill(ticks), RETRY_TIMEOUT); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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.