tests: Change most uses of "raise" with 0 args to have 1 arg.#19245
Open
dpgeorge wants to merge 2 commits into
Open
tests: Change most uses of "raise" with 0 args to have 1 arg.#19245dpgeorge wants to merge 2 commits into
dpgeorge wants to merge 2 commits into
Conversation
The native emitter cannot generate code for "raise" (re-raising) or "raise x from y" (exception chaining). Trying to generate such code can happen in normal programs, so raise an NotImplementedError instead of using an assert (that won't even be enabled in most production builds). And add a coverage test for this new exception. Signed-off-by: Damien George <damien@micropython.org>
This allows these tests to run with the native emitter. The only remaining raise-with-0-args are in tests than specifically check this re-raise behaviour. Signed-off-by: Damien George <damien@micropython.org>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19245 +/- ##
=======================================
Coverage 98.47% 98.47%
=======================================
Files 176 176
Lines 22845 22846 +1
=======================================
+ Hits 22497 22498 +1
Misses 348 348 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Code size report: |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The native emitter cannot compile "raise" without exactly one argument. Some tests use raise-without-args and are
explicitly skipped with the native emitter, while others used it without being skipped and crash the device.
Two things to address that:
NotImplementedErrorin the compiler instead of crashing/assertingThe only remaining raise-with-0-args are in tests than specifically check this re-raise behaviour.
Testing
net_inettests with the native emitter (on unix port).A coverage test is added for the new exception.
Trade-offs and Alternatives
This adds a bit of code size for the new exception in the native emitter, but that's a lot better than crashing/asserting without a good indication of why.
Generative AI
I did not use generative AI tools when creating this PR.