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

doc: update tests to avoid running in parallel #1024

Closed
wants to merge 4 commits into from

Conversation

mhdawson
Copy link
Member

fixes: #1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermittent
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson mdawson@devrus.com

fixes: nodejs#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>
Signed-off-by: Michael Dawson <mdawson@devrus.com>
@mhdawson
Copy link
Member Author

@nodejs/node-api anybody have a windows machine who can check what's up with the symbol test on windows? I'm not sure how the change would have broken just for windows?

@NickNaso
Copy link
Member

NickNaso commented Jul 21, 2021

Hi @mhdawson,
it seems that when we call the function assertSymbolIsWellknown (https://github.com/nodejs/node-addon-api/blob/main/test/symbol.js#L30) for the symbol matchAll we get undefined and the test fail.
If I do the same in native JavaScript:

'use strict'
const assert = require('assert')

const symbols = ['iterator', 'matchAll']

for (const symbol of symbols) {
    const symbOne = Symbol.for(symbol);
    const symbTwo = Symbol.for(symbol);
    assert(symbOne && symbTwo);
    assert(symbOne === symbTwo);
}

for (const symbol of symbols) {
    const symbOne = global.Symbol[symbol]
    const symbTwo = global.Symbol[symbol]
    assert(symbOne && symbTwo);
    assert(symbOne === symbTwo);
}

In the example above the second series of test fails. This happens becasue Napi::Symbol::Wellknown is implemented like reported below:

inline Symbol Symbol::WellKnown(napi_env env, const std::string& name) {
  return Napi::Env(env).Global().Get("Symbol").As<Object>().Get(name).As<Symbol>();
}

To obtain a well-known symbols we try to get it from the global object.
In Node.js 10.x and Windows if you try to get the matchAll symbol through a global object global.Symbol.matchAll you will get undefined.
The MSDN documentation reports that matchAll symbol is fully supported on Node.js 12.0.0 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/matchAll#browser_compatibility

@mhdawson
Copy link
Member Author

@NickNaso thanks! Strange that it is found on linux but not windows.

@@ -101,3 +101,10 @@ exports.runTestWithBindingPath = async function(test, buildType) {
await test(item);
}
}

exports.runTestNoBinding = async function(test, buildType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above two helpers are named with their parameters:

  • runTest(test: (binding) => Promise<void>)
  • runTestWithBindingPath(test: (bindingPath) => Promise<void>)

Maybe we can name this as runTestWithBuildType so that we can assume the first parameter of the test function is buildType?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legendecas that makes sense to me will update.

@mhdawson
Copy link
Member Author

@NickNaso this is what I see on linux

[midawson@drx-hemera node]$ cat test.js
console.log(global.Symbol.matchAll);
console.log(global.Symbol['matchAll']);
[midawson@drx-hemera node]$ ./node test.js
Symbol(Symbol.matchAll)
Symbol(Symbol.matchAll)

From what I understand you get undefined on windows instead, right ?

@mhdawson
Copy link
Member Author

@NickNaso, I thinkI understand you now, sounds like we should only test for that symbol on 12.x and above

@NickNaso
Copy link
Member

@NickNaso this is what I see on linux

[midawson@drx-hemera node]$ cat test.js
console.log(global.Symbol.matchAll);
console.log(global.Symbol['matchAll']);
[midawson@drx-hemera node]$ ./node test.js
Symbol(Symbol.matchAll)
Symbol(Symbol.matchAll)

From what I understand you get undefined on windows instead, right ?

Yes on Windows, but only with Node.js 10.x I get undefined.

Only check for the matchAll symbol on 12.x and above

Signed-off-by: Michael Dawson <mdawson@devrus.com>
Signed-off-by: Michael Dawson <mdawson@devrus.com>
mhdawson added a commit that referenced this pull request Jul 27, 2021
fixes: #1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: #1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
@mhdawson
Copy link
Member Author

Landed as a459f5c

@mhdawson mhdawson closed this Jul 27, 2021
deepakrkris pushed a commit to deepakrkris/node-addon-api that referenced this pull request Sep 23, 2021
fixes: nodejs#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
deepakrkris pushed a commit to deepakrkris/node-addon-api that referenced this pull request Oct 15, 2021
fixes: nodejs#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
fixes: nodejs/node-addon-api#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs/node-addon-api#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
fixes: nodejs/node-addon-api#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs/node-addon-api#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
fixes: nodejs/node-addon-api#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs/node-addon-api#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
austinli64 added a commit to austinli64/node-addon-api that referenced this pull request May 9, 2023
fixes: nodejs/node-addon-api#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs/node-addon-api#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
fixes: nodejs/node-addon-api#1022

The objectwrap_worker_thread and symbol tests
were not waiting for the test to complete before the
subsequent tests were started. This caused intermitted
crashes in the CI.

Updated both tests so that they complete before the
next test runs.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: nodejs/node-addon-api#1024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent crashes in CI
3 participants