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

test(semver): add missing tests #6362

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

timreichen
Copy link
Contributor

No description provided.

@timreichen timreichen requested a review from kt3k as a code owner January 24, 2025 08:10
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.29%. Comparing base (3b75ee7) to head (fb67093).

Files with missing lines Patch % Lines
semver/parse_range.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6362      +/-   ##
==========================================
+ Coverage   96.23%   96.29%   +0.06%     
==========================================
  Files         556      556              
  Lines       42065    42063       -2     
  Branches     6371     6371              
==========================================
+ Hits        40481    40506      +25     
+ Misses       1544     1518      -26     
+ Partials       40       39       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

prerelease: [],
build: [],
}]];
assertEquals(greaterThanRange(version, range), true);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this result is correct

I also just realized != is not a valid operator in npm:semver (semver.gtr("1.0.0", "!=1.0.0") throws with invalid operator error, and docs doesn't mention != https://github.com/npm/node-semver?tab=readme-ov-file#ranges

I'd suggest we should skip this particular test case for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of skipping, we probably should add the test and remove it when handling the problem/bug.

Copy link
Member

Choose a reason for hiding this comment

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

Then can you add a TODO comment above the test title, which says that this is a bug, not an intentional behavior?

prerelease: [],
build: [],
}]];
assertEquals(lessThanRange(version, range), true);
Copy link
Member

Choose a reason for hiding this comment

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

This result feels wrong to me. I'd suggest skipping this test case for now

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 think we should not skip test cases if they yield unexpected results but fix them instead. What would the proper result be?

Copy link
Member

Choose a reason for hiding this comment

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

What would the proper result be?

The range != 1.0.0 should include all versions except 1.0.0. So I think the expected result here is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to create a PR to remove the != straight away as a bug fix before landing this PR? This probably solves lots of headaches with intermediate patches.

Comment on lines +671 to +676
assertEquals(parseRange("<1.*"), [
[{ operator: "<", major: 1, minor: 0, patch: 0 }],
]);
assertEquals(parseRange("<1.*.0"), [
[{ operator: "<", major: 1, minor: NaN, patch: 0 }],
]);
Copy link
Member

Choose a reason for hiding this comment

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

The difference of these 2 results seem strange to me. Is this intentionally in this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems indeed wrong. Imo <1.*.0 should be an invalid range and throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

});

Deno.test({
name: "compare() handles undefined in prerelease",
Copy link
Member

Choose a reason for hiding this comment

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

This test case looks comparing invalid semvers. I don't think this is an intentional behavior, but an undefined behavior. I'd suggest we should remove this test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants