Repository navigation
tests/run-tests.py: Ensure correct cwd for mpy tests. - #11468
Merged
Merged
Conversation
Member
Author
|
Related to #6909 which I still like the idea of (because it's easier to reason about a test that runs in an isolated environment), but I don't think is necessary. |
Member
|
Thanks, this looks good to me. |
Member
Author
|
I don't think this is strictly necessary for #11456 any more since we decided to make |
Previously when using --via-mpy, the file was compiled to tests/<tmp>.mpy and then run using `micropython -m <tmp>` in the current cwd (usually tests/). This meant that an import in the test would be resolved relative to tests/. This is different to regular (non-via-mpy) tests, where we run (for example) `micropython basics/test.py` which means that an import would be resolved relative to basics/. Now --via-mpy matches the .py behavior. This is important because: a) It makes it so import tests do the right thing. b) There are directory names in tests/ that match built-in module names. Furthermore, it always ensures the cwd (for both micropython and cpython) is the test directory (e.g. basics/) rather than being left unset. This also makes it clearer inside the test that e.g. file access is relative to the Python file. Updated tests with file paths to match. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
dpgeorge
force-pushed
the
tests-via-mpy-cwd
branch
from
May 18, 2023 03:53
c4da44c to
17127bb
Compare
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.
This is necessary for #11456 which currently fails the --via-mpy tests due
import micropythonnow attempting to import tests/micropython, but I think it's overall a good fix to improve consistency anyway.Previously when using --via-mpy, the file was compiled to tests/.mpy and then run using
micropython -m <tmp>in the current cwd (usually tests/). This meant that an import in the test would be resolved relative to tests/.This is different to regular (non-via-mpy) tests, where we run (for example)
micropython basics/test.pywhich means that an import would be resolved relative to basics/.Now --via-mpy matches the .py behavior. This is important because: a) It makes it so import tests do the right thing. b) There are directory names in tests/ that match built-in module names.
Furthermore, it always ensures the cwd (for both micropython and cpython) is the test directory (e.g. basics/) rather than being left unset. This also makes it clearer inside the test that e.g. file access is relative to the Python file. Updated tests with file paths to match.
This work was funded through GitHub Sponsors.