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

Fix race condition bug in test, and show assertion failure values #16037

Closed
wants to merge 4 commits into from
Closed

Fix race condition bug in test, and show assertion failure values #16037

wants to merge 4 commits into from

Conversation

kkwoker
Copy link
Contributor

@kkwoker kkwoker commented Oct 6, 2017

Two changes:

  1. Fixed a bug in the test where the expected_result was caught in a race condition with the first two tests using promises.
  2. Cosmetic fixes for the test by removing the strings, making the assert return failure values.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added dont-land-on-v4.x node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests. labels Oct 6, 2017
@Trott Trott added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Oct 6, 2017
@joyeecheung
Copy link
Member

test_promise.concludeCurrentPromise(expected_result, true);
{
let expected_result = 42;
promise = test_promise.createPromise();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: declare promise which is now a scoped var as const.

@refack
Copy link
Contributor

refack commented Oct 7, 2017

Except for lint error:

not ok 37 - /usr/home/iojs/build/workspace/node-test-linter/test/addons-napi/test_promise/test.js
  ---
  message: '''expected_result'' is never reassigned. Use ''const'' instead.'
  severity: error
  data:
    line: 11
    column: 7
    ruleId: prefer-const
  messages:
    - message: '''expected_result'' is never reassigned. Use ''const'' instead.'
      severity: error
      data:
        line: 24
        column: 7
        ruleId: prefer-const
  ...

CI is clean (CentOS5 failure is irrelevant)

@refack refack self-assigned this Oct 7, 2017
@refack
Copy link
Contributor

refack commented Oct 7, 2017

Welcome @kkwoker, and thank you for the contribution 🥇
Hope you find the time to follow up on this PR.


assert.strictEqual(test_promise.isPromise({}), false,
'an object is recognized as not a promise');
assert.strictEqual(test_promise.isPromise({}), false);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I would prefer not to have single lines separated by empty lines for assertions.

@kkwoker
Copy link
Contributor Author

kkwoker commented Oct 7, 2017

Hi, thank you for your help! I made the relevant fixes from your suggestions

@refack
Copy link
Contributor

refack commented Oct 7, 2017

@kkwoker thank you for following up.
Linter is now green - https://ci.nodejs.org/job/node-test-linter/12314/ ✔️

P.S. You had some unrelated commits from master in this PR so I rebased and force pushed. You can sync up by running git pull --rebase

@joyeecheung
Copy link
Member

refack pushed a commit that referenced this pull request Oct 9, 2017
PR-URL: #16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@refack
Copy link
Contributor

refack commented Oct 9, 2017

Landed in 84579b1

@kkwoker congratulations on being promoted from
image
to
image
🍾

@refack refack closed this Oct 9, 2017
MylesBorins pushed a commit that referenced this pull request Oct 11, 2017
PR-URL: #16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Oct 11, 2017
addaleax pushed a commit to addaleax/ayo that referenced this pull request Oct 12, 2017
PR-URL: nodejs/node#16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 16, 2018
PR-URL: nodejs#16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Backport-PR-URL: #19447
PR-URL: #16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Apr 16, 2018
@refack refack removed their assignment Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants