-
Notifications
You must be signed in to change notification settings - Fork 264
Change to the iOS testing option semantics #2363
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
base: main
Are you sure you want to change the base?
Conversation
Don't assume the presence of `python -m` in the test command. Less magic and allows more option reuse between platforms.
Is this required on Pyodide too? I seem to remember |
I think it's a bit up in the air, but currently on macOS, |
I think this is better; in fact, I'd also be fine if not starting with |
Interesting - I had a similar set of thoughts about this in the process of developing that particular feature. At the time, my thinking went the other direction: preferring the "short" form, and auto-stripping The approach you've taken here makes more sense to me, and seems like it would ultimately be more robust. Yes-anding this proposal - there are other predictable error conditions that we could catch in the case where the string doesn't start with |
Yeah, that's a nice idea. I'd be open to adding it if it's neat. Another thought I had- What should we do with the test-command if it includes other python flags, e.g.
I think my preference is (1) - it's the most 'honest' version of this, since we'd be discarding any other interpreter flags anyway. |
I agree. Trying to parse the Python command line is going to be error prone at best. In the context of iOS, other Python command line arguments aren't going to be processed, so doing complex parsing to "pretend" that we are seems like asking for trouble. |
ee30330
to
96bd43c
Compare
Whoops! Apologies if you saw some extra commits here, they were meant for a different branch. Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all makes sense to me - a couple of minor edge cases in testing flagged inline.
test/test_ios.py
Outdated
expected_wheels = utils.expected_wheels( | ||
"spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a user-defined IPHONEOS_DEPLOYMENT_TARGET
will no longer be considered as part of the expected wheel names?
expected_wheels = utils.expected_wheels( | |
"spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] | |
) | |
expected_wheels = utils.expected_wheels( | |
"spam", | |
"0.1.0", | |
platform="ios", | |
python_abi_tags=["cp313-cp313"], | |
iphoneos_deployment_target=os.getenv("IPHONEOS_DEPLOYMENT_TARGET", "13.0"), | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the environment access to expected_wheels. BTW, if this is left unset, does a part of the toolchain set it, or is it determined by the iOS SDK used? I'm just wondering how good of a default "13.0" is.
In the bitarray package I found another example of a test command pattern which we should probably support, something of the form:
This could be passed to the testbed and executed using |
Conceptually, sure; but it would need changes in the iOS testbed to support this. The testbed currently assumes a test can be executed as |
In python/cpython#132870 I've generalized the Android testbed script to have
But the bitarray example also raises another question, which is independent of the form of the test command. iOS requires I can see a few possible solutions:
I'm leaning towards the last one, because it maximizes the number of packages which will work without modification. |
The downside to the Of the options you gave, my preference would be (2) - that you have to specify something, but an empty list is an acceptable answer. There is, of course, a fourth option that you didn't suggest: "Don't do that" :-) That is, encourage apps to have an actual test suite, rather than embedding test code in app code, by requiring a standalone test suite. That's possibly a little opinionated... but I don't think it's an entirely unreasonable position to hold. |
Regarding Regarding the case of unnecessary
Probably the answer is to just "run isolated without files". But it means we now lack a way to override to the behaviour "run from project tree". It seems a shame to lose a feature for the sake of a rare edge-case. I'd be open to 'do nothing'. The user could just workaround this with something silly, like test-sources = "README.md". I'd also submit a fifth option, a documented special value for test-sources:
|
Agreed, so setting
Both of these things would also happen on desktop platforms when running the tests from the project directory, so at least we'd be consistent.
In this case there is an alternative entry point that can be run with So I've added
OK, let's go with that for now – I'll add it to the documentation in the Android PR. If this turns out to be a common situation, then we can revisit this later. |
cc @freakboy3742
I've been thinking about the test-command option, and the implicit addition of
python -m
.pytest
is gonna be pretty confusing for users. e.g.test-command = "python ./my-tests.py"
->python: No module named python
python -m mymodule.tests
they have to define it twice, once as-is and again for iOS asmymodule.tests
My thought was that we could require test commands on ios start with
python -m
, but with a warning and an auto-fixup where that doesn't occur. That way bad configs always get a warning, and we allow more option reuse between platforms.I'd want to add a test for this, so just raising as draft for discussion for now.