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: tap parser fails when test name includes non ASCII characters #45741

Closed
wants to merge 2 commits into from

Conversation

pulkit-30
Copy link
Contributor

@pulkit-30 pulkit-30 commented Dec 5, 2022

fixes: #45706

fix: tap parser fails when test name includes non ASCII characters

check for non-ascii characters and return true if it is not.

function to check for non-ASCII characters:

  #isNonASCIISymbol(char) {
    const ascii = /^[ -~]+$/;
    return !ascii.test(char);
  }

Example:

Testing:

// test.mjs
import { it } from 'node:test'
it('नमस्ते', () => {});

Output:

TAP version 13
# Subtest: /Users/pulkitgupta/Desktop/node/test.mjs
    # Subtest: नमस्ते
ok 1 - नमस्ते
    # duration_ms:
ok 1 - /Users/pulkitgupta/Desktop/node/test.mjs
  ---
  duration_ms: 59.161084
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 61.073625
pulkitgupta@Pulkits-MacBook-Air node % 

@nodejs-github-bot 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 Dec 5, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

Can you please add a test to validate this indeed fixes the bug?

@@ -482,6 +483,11 @@ class TapLexer {
return '!"$%&\'()*,./:;<=>?@[]^_`{|}~'.indexOf(char) > -1;
}

#isNonASCIISymbol(char) {
const ascii = /^[ -~]+$/;
return !ascii.test(char);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return !ascii.test(char);
return RegExpPrototypeExec(ascii, char) === null;

@pulkit-30
Copy link
Contributor Author

pulkit-30 commented Dec 5, 2022

Can you please add a test to validate this indeed fixes the bug?

Sure, Where should I add test ?

@aduh95
Copy link
Contributor

aduh95 commented Dec 5, 2022

Can you please add a test to validate this indeed fixes the bug?

Sure, Where should I add test ?

test/parallel/test-runner-tap-lexer.js seems adequate.

@MoLow
Copy link
Member

MoLow commented Dec 5, 2022

@pulkit-30 FYI there is already an open PR fixing this issue #45736

@pulkit-30
Copy link
Contributor Author

pulkit-30 commented Dec 5, 2022

@pulkit-30 FYI there is already an open PR fixing this issue #45736

ohh! I didn't notice that, should I close this PR?

@MoLow
Copy link
Member

MoLow commented Dec 5, 2022

ohh! I didn't notice that, should I close this PR?

preferably, I see you found another good first issue Issues that are suitable for first-time contributors. to work on - so I am closing

@MoLow MoLow closed this Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 when test name includes non ASCII characters
4 participants