-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
test: Make N-API weak-ref GC tests asynchronous #13121
Conversation
value = null; | ||
global.gc(); // Value should NOT be GC'd because there is a strong ref | ||
assert.strictEqual(test_reference.finalizeCount, 0); | ||
'External value without a finalizer', |
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.
Would it be better to make it an array of objects instead of doing the string check for the title ?
ex
{ title: 'External value without a finalizer', steps: [() => {...}, () => {...}, etc ]}
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.
That would work too, but would be more complicated to do the nested iteration recursively. I didn't see a need to over-design this just for these few tests. I can do it if you want. :)
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.
I was thinking it would actually be easier/less code, but if you don't think that's the case I don't want to hold up getting this landed. I may take a look/PR later on when I have time if what I was thinking can simply, if not then I'll leave it be.
- Make GC tests (arraybuffer, buffer) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.)
title = tests[i]; | ||
runTests(i + 1, title, tests); | ||
} else { | ||
try { |
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.
Couldn't you replace the try...catch
, throw
, and console.error()
call with a call to assert.doesNotThrow()
?
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.
That could work, except assert.doesNotThrow()
loses the stack trace of the original exception; it only displays the message. So I prefer not to use it except when checking for a very specific exceptional condition. In this case, the original exception stack trace is likely to point to a line number of another assertion in the file, so that's very helpful information.
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.)
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.) - Fix improper rethrow of an Error caught by reference that caused a double napi_ref delete, which failed in release builds of Node-ChakraCore.
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.
LGTM
One of the N-API weak-reference test cases already had to be made asynchronous to handle different behavior in a newer V8 version: nodejs#12864 When porting N-API to Node-ChakraCore, we found more of the test cases needed similar treatment: nodejs/node-chakracore#246 So to make thes tests more robust (and avoid having differences in the test code for Node-ChakraCore), I am refactoring the tests in this file to insert a `setImmedate()` callback before every call to `gc()` and assertions about the effects of the GC. PR-URL: nodejs#13121 Reviewed-By: Michael Dawson <[email protected]>
6334a1b
to
bb91879
Compare
Landed as bb91879 |
One of the N-API weak-reference test cases already had to be made asynchronous to handle different behavior in a newer V8 version: #12864 When porting N-API to Node-ChakraCore, we found more of the test cases needed similar treatment: nodejs/node-chakracore#246 So to make thes tests more robust (and avoid having differences in the test code for Node-ChakraCore), I am refactoring the tests in this file to insert a `setImmedate()` callback before every call to `gc()` and assertions about the effects of the GC. PR-URL: #13121 Reviewed-By: Michael Dawson <[email protected]>
Fixed by upstream PR nodejs/node#13121 Resolves nodejs#246
Fixed by upstream PR nodejs/node#13121 Resolves nodejs#246 PR-URL: nodejs#301 Reviewed-By: Kunal Pathak <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixed by upstream PR nodejs/node#13121 Resolves nodejs#246 PR-URL: nodejs#301 Reviewed-By: Kunal Pathak <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
One of the N-API weak-reference test cases already had to be made asynchronous to handle different behavior in a newer V8 version: nodejs#12864 When porting N-API to Node-ChakraCore, we found more of the test cases needed similar treatment: nodejs/node-chakracore#246 So to make thes tests more robust (and avoid having differences in the test code for Node-ChakraCore), I am refactoring the tests in this file to insert a `setImmedate()` callback before every call to `gc()` and assertions about the effects of the GC. PR-URL: nodejs#13121 Reviewed-By: Michael Dawson <[email protected]>
One of the N-API weak-reference test cases already had to be made asynchronous to handle different behavior in a newer V8 version: #12864 When porting N-API to Node-ChakraCore, we found more of the test cases needed similar treatment: nodejs/node-chakracore#246 So to make thes tests more robust (and avoid having differences in the test code for Node-ChakraCore), I am refactoring the tests in this file to insert a `setImmedate()` callback before every call to `gc()` and assertions about the effects of the GC. Backport-PR-URL: #19447 PR-URL: #13121 Reviewed-By: Michael Dawson <[email protected]>
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.) - Fix improper rethrow of an Error caught by reference that caused a double napi_ref delete, which failed in release builds of Node-ChakraCore.
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.) - Fix improper rethrow of an Error caught by reference that caused a double napi_ref delete, which failed in release builds of Node-ChakraCore.
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.) - Fix improper rethrow of an Error caught by reference that caused a double napi_ref delete, which failed in release builds of Node-ChakraCore.
- Make GC tests (arraybuffer, buffer, external) async, to account for different GC behavior with different versions of V8 and ChakraCore, similar to nodejs/node#13121 - In test/index.js, use the --napi-modules and --expose-gc command-line flags automatically. - Add missing entry for object tests in index.js. - Remove check for writable attribute on accessor property descriptors; it should not be there according to the JS spec. - Remove the explicit dependency on node-gyp in package.json. (NPM carries its own copy of node-gyp.) - Fix improper rethrow of an Error caught by reference that caused a double napi_ref delete, which failed in release builds of Node-ChakraCore.
One of the N-API weak-reference test cases already had to be made asynchronous to handle different behavior in a newer V8 version. (0a734fe) When porting N-API to Node-ChakraCore, we found more of the test cases needed similar treatment. (nodejs/node-chakracore#246) So to make thes tests more robust (and avoid having differences in the test code for Node-ChakraCore), I am refactoring the tests in this file to insert a
setImmedate()
callback before every call togc()
and assertions about the effects of the GC.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test