Skip to content
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
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix code style
fix warn message
fix comment style
  • Loading branch information
killagu committed Feb 17, 2018
commit a43951e5460ec73611fc656ee44c489b472527fa
2 changes: 1 addition & 1 deletion lib/internal/v8_prof_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function readline() {
return '';
}
if (bytes === 0) {
process.emitWarning('profile file is broken', {
process.emitWarning(`Profile file ${logFile} is broken`, {
code: 'BROKEN_PROFILE_FILE',
detail: `${JSON.stringify(line)} at the file end is broken`
});
Expand Down
14 changes: 8 additions & 6 deletions test/tick-processor/test-tick-processor-polyfill-brokenfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ if (!common.enoughTestCpu)
common.skip('test is CPU-intensive');
Copy link
Member

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? :-)

Copy link
Contributor Author

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.


if (common.isCPPSymbolsNotMapped) {
common.skip('C++ symbols are not mapped for this os.');
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
// This test will produce a broken profile log.
// ensure prof-polyfill not stuck in infinite loop
// and success process


const assert = require('assert');
Expand All @@ -23,7 +23,8 @@ 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 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();
Expand Down Expand Up @@ -54,7 +55,8 @@ function runPolyfill(content) {
'--prof-process', LOG_FILE
]);
assert(WARN_REG_EXP.test(child.stderr.toString()));
assert.strictEqual(child.status, 0, 'broken file should success too');
assert(WARN_DETAIL_REG_EXP.test(child.stderr.toString()));
assert.strictEqual(child.status, 0);
}

setTimeout(() => runPolyfill(ticks), RETRY_TIMEOUT);