Skip to content

test(NODE-3719): reorganize spec tests and remove unneeded skips #486

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

Merged
merged 3 commits into from
Feb 11, 2022

Conversation

dariakp
Copy link
Contributor

@dariakp dariakp commented Feb 9, 2022

Description

NODE-3719

What is changing?

Spec test organization

Is there new documentation needed for these changes?

N/A

What is the motivation for this change?

Spec compliance review

Double check the following

  • Ran npm run lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@dariakp dariakp force-pushed the NODE-3719/bson-spec-compliance branch from 8517a36 to 6150a8d Compare February 9, 2022 23:00
Copy link
Contributor Author

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Along with the comment below:

  1. I noticed that specs/object-id might be dead code, I haven't been able to find any reference to vectors.json in the actual specs repo and nothing seems to be loading these ones
  2. decodeErrors only checks expect(() => BSON.deserialize(B, deserializeOptions)).to.throw(); - is it intentionally general or should we be checking for a better error? If so, NODE-3637 may be a good ticket to tack that work onto
  3. There are a number of skipped tests with comments but no TODOs, it would be good to either definitively say "we'll never implement this", or to file actual backlog tickets to make sure that if we do implement relevant functionality, those tests get unskipped
const skipBSON = {
  'NaN with payload':
    'passing this would require building a custom type to store the NaN payload data.'
};
// tests from the corpus that we need to skip, and explanations why
const skipExtendedJSON = {
  'Timestamp with high-order bit set on both seconds and increment':
    'Current BSON implementation of timestamp/long cannot hold these values - 1 too large.',
  'Timestamp with high-order bit set on both seconds and increment (not UINT32_MAX)':
    'Current BSON implementation of timestamp/long cannot hold these values - 1 too large.'
};

const SKIP_TESTS = new Map([
  ...Object.entries(skipBSON),
  ...Object.entries(skipExtendedJSON),
  [
    'All BSON types',
    'there is just too much variation in the specified expectation to make this work'
  ]
]);


it('Flags/options for a regular expression', () => {
expect(() => BSON.serialize({ a: new BSONRegExp('a', 'i\x00m') })).to.throw(/null bytes/);
// TODO: should we test RegExp, too?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember if there is a reason why we test RegExp in the block above but not in this one

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't put null bytes into the native regex constructor, it's a SyntaxError so we're covered 😎

> new RegExp('a', '\x00i')
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'i'
> new RegExp('a', 'i\x00')
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'i'

@dariakp dariakp requested a review from nbbeeken February 9, 2022 23:09
@nbbeeken
Copy link
Contributor

nbbeeken commented Feb 9, 2022

The 'NaN with payload' test could be marked with a todo for https://jira.mongodb.org/browse/NODE-3630 and maybe we pull that ticket into spec compliance

@dariakp dariakp marked this pull request as ready for review February 10, 2022 21:42
@dariakp dariakp changed the title test(NODE-3719): reorganize spec tests for visibility test(NODE-3719): reorganize spec tests and remove unneeded skips Feb 10, 2022
@nbbeeken
Copy link
Contributor

CI failures aren't a blocker, I've opened #487 to address some issues.

@nbbeeken nbbeeken added the Team Review Needs review from team label Feb 10, 2022
@dariakp dariakp merged commit 79cb5d3 into master Feb 11, 2022
@dariakp dariakp deleted the NODE-3719/bson-spec-compliance branch February 11, 2022 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants