FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: fix tap parser fails if a test logs a number by pulkit-30 · Pull Request #46056 · nodejs/node · GitHub

/ node Public

test: fix tap parser fails if a test logs a number - #46056

Merged
nodejs-github-bot merged 8 commits into
nodejs:mainfrom
pulkit-30:fix-46048
Feb 6, 2023
Merged

test: fix tap parser fails if a test logs a number#46056
nodejs-github-bot merged 8 commits into
nodejs:mainfrom
pulkit-30:fix-46048

Conversation

pulkit-30 commented Jan 2, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

fixes: #46048

code: test.mjs

import test from 'node:test';

test('test 1');

test('testing', () => {
  console.log(-123);
  console.log(123);
  console.log('-123');
  console.log('123');
  console.log('a 123');
  console.log(123, '123');
  console.log('123', 123);
  console.log('123', 'a');
  console.log('123 abc');
  console.log('abc 123');
});

test('test 3');

Before changes:

TAP version 13
# Subtest: /Users/pulkitgupta/Desktop/node/test.mjs
not ok 1 - /Users/pulkitgupta/Desktop/node/test.mjs
  ---
  duration_ms: 40.977208
  failureType: 'uncaughtException'
  error: "Cannot read properties of undefined (reading 'value')"
  code: 'ERR_TEST_FAILURE'
  stack: |-
    #Plan (node:internal/test_runner/tap_parser:653:20)
    #TAPDocument (node:internal/test_runner/tap_parser:552:28)
    #parseChunk (node:internal/test_runner/tap_parser:274:35)
    #parseTokens (node:internal/test_runner/tap_parser:249:23)
    TapParser.parse (node:internal/test_runner/tap_parser:105:24)
    TapParser._transform (node:internal/test_runner/tap_parser:187:10)
    Transform._write (node:internal/streams/transform:175:8)
    writeOrBuffer (node:internal/streams/writable:392:12)
    _write (node:internal/streams/writable:333:10)
    Writable.write (node:internal/streams/writable:337:10)
  ...
1..1
# tests 1
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 52.074334

After changes:

TAP version 13
# Subtest: /Users/pulkitgupta/Desktop/node/test.mjs
    # -123
    # 123
    # -123
    # 123
    # a 123
    # 123 123
    # 123 123
    # 123 a
    # 123 abc
    # abc 123
    # Subtest: test 1
    ok 1 - test 1
      ---
      duration_ms: 0.677875
      ...
    # Subtest: testing
    ok 2 - testing
      ---
      duration_ms: 0.911917
      ...
    # Subtest: test 3
    ok 3 - test 3
      ---
      duration_ms: 0.041959
      ...
    1..3
ok 1 - /Users/pulkitgupta/Desktop/node/test.mjs
  ---
  duration_ms: 52.6225
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 54.201375

I tried to fix this bug, let me know if these changes are acceptable or to be done at some other place.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

nodejs-github-bot added dont-land-on-v14.x needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Jan 2, 2023

aduh95 commented Jan 2, 2023

Copy link
Copy Markdown
Contributor

Can you add a test case?

Copy link
Copy Markdown
Contributor Author

Can you add a test case?

Sure.
also fixing failed checks. 🚀

pulkit-30 marked this pull request as draft January 2, 2023 10:11
pulkit-30 marked this pull request as ready for review January 2, 2023 13:18

Copy link
Copy Markdown
Contributor Author

Hey @cjihrig @manekinekko,

Have a look at these changes,
By this we are ignoring invalid Tap syntax from parsing & also displaying it as a diagnostic.
Also added test-case for same here.

manekinekko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The fix LGTM. However, I'd recommend moving the fix to the upper-level logic of the parser since we need to catch all possible invalid syntax encountered by each nested parsing rule.

The most common top-level parsing rule is TAPDocument().

Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated

pulkit-30 commented Jan 10, 2023
edited
Loading

Copy link
Copy Markdown
Contributor Author

Thanks @adhu95 for suggestions,
I think we should add planStart, planToken and planEnd as private member of class TapParser.

Then we don't need to pass planStart and planEnd as an argument to #Plan method...? WDYT?

aduh95 commented Jan 10, 2023

Copy link
Copy Markdown
Contributor

I think we should add planStart, planToken and planEnd as private member of class TapParser.

Then we don't need to pass planStart and planEnd as an argument to #Plan method...? WDYT?

I don't think it's a good idea, unless I'm missing something it looks like it makes more sense to keep them as arguments.

Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
Comment thread lib/internal/test_runner/tap_parser.js Outdated
pulkit-30 requested review from aduh95 and manekinekko and removed request for aduh95 and manekinekko January 11, 2023 03:17
MoLow added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Feb 5, 2023
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 5, 2023

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor Author

There are some failing checks, is there anything wrong with this Pull Request?
let me know, I will fix them

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

MoLow requested a review from aduh95 February 6, 2023 13:52
MoLow added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Feb 6, 2023
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 6, 2023
nodejs-github-bot merged commit 4c08c20 into nodejs:main Feb 6, 2023

Copy link
Copy Markdown
Collaborator

Landed in 4c08c20

Copy link
Copy Markdown
Contributor

Congratulations @pulkit-30 🎉

Copy link
Copy Markdown
Contributor Author

Congratulations @pulkit-30 🎉

Thanks a lot @manekinekko for your support and reviews 😇

MoLow pushed a commit to MoLow/node-core-test that referenced this pull request Feb 7, 2023
PR-URL: nodejs/node#46056
Fixes: nodejs/node#46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 4c08c20e575a0954fe3977a20e9f52b4980a2e48)
MoLow pushed a commit to nodejs/node-core-test that referenced this pull request Feb 8, 2023
PR-URL: nodejs/node#46056
Fixes: nodejs/node#46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 4c08c20e575a0954fe3977a20e9f52b4980a2e48)
MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
PR-URL: #46056
Fixes: #46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MylesBorins mentioned this pull request Feb 19, 2023
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
PR-URL: nodejs#46056
Fixes: nodejs#46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
PR-URL: #46056
Backport-PR-URL: #46839
Fixes: #46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
juanarbol mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
PR-URL: #46056
Backport-PR-URL: #46839
Fixes: #46048
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tap parser fails if a test logs a number

6 participants


Back | FazBrowse Home | New Git URL