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 SimpleModuleLoader on Windows #3795

Merged
merged 1 commit into from
Apr 9, 2024
Merged

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Apr 7, 2024

Basically I made a mistake with my previous PR and discovered it as I was building embed_module!.

Copy link

codecov bot commented Apr 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.22%. Comparing base (6ddc2b4) to head (2609952).
Report is 123 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3795      +/-   ##
==========================================
+ Coverage   47.24%   50.22%   +2.98%     
==========================================
  Files         476      456      -20     
  Lines       46892    44823    -2069     
==========================================
+ Hits        22154    22514     +360     
+ Misses      24738    22309    -2429     

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

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

To avoid the same error in the future, maybe the test should be changed to test the path components instead of the whole path string.

EDIT: Just realized that this change could also deduplicate the tests.

@hansl
Copy link
Contributor Author

hansl commented Apr 9, 2024

I don't think we would gain anything from checking the path components, but I'll make the change. There was a bug in the code and the tests were built to test the bug, so both were faulty. It happens.

(as proof that the bug was in the test AND the code, I didn't change the expected value, just the argument itself)

@jedel1043
Copy link
Member

I don't think we would gain anything from checking the path components, but I'll make the change. There was a bug in the code and the tests were built to test the bug, so both were faulty. It happens.

But the bug passed the test because we were using separators on the test itself, right? If I'm correct, testing by components instead of using separators would have caught the bug.

@hansl
Copy link
Contributor Author

hansl commented Apr 9, 2024

But the bug passed the test because we were using separators on the test itself, right?

The bug was two fold:

  1. in JavaScript you'd always use ./a/b/c in your import specifier, even on Windows. I was generating a path using the specifier, but didn't change the \\ to /, so if you were on Windows and used a/b/c it would have been a:\some\root\a/b/c which would be shown in components (as you said).
  2. the test was actually wrong in that it passed ./a\\b\\c for specifier, and so Windows was returning the expected path but for the wrong reason. That's what I mean by I was "testing the bug". This meant that even doing a component check would still result in the right answer, because the test input was wrong. Changing the specifier in the test to be ./a/b/c then showed the bug, which I fixed in this PR as well.

I might be over explaining. We can sync offline tomorrow morning if you or I are missing something. Cheers!

@jedel1043
Copy link
Member

That makes a lot of sense. Thank you for explaining!

@hansl hansl requested a review from jedel1043 April 9, 2024 02:56
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@HalidOdat HalidOdat requested a review from a team April 9, 2024 13:56
@jedel1043 jedel1043 added this pull request to the merge queue Apr 9, 2024
Merged via the queue into boa-dev:main with commit 1825e8b Apr 9, 2024
14 checks passed
@hansl hansl deleted the fix-windows-imports branch April 9, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants