Opened 3 years ago
Closed 2 years ago
#64241 closed enhancement (fixed)
python portgroup: add opt-in test support
Reported by: | mascguy (Christopher Nielsen) | Owned by: | mascguy (Christopher Nielsen) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.7.1 |
Keywords: | tests | Cc: | reneeotten (Renee Otten) |
Port: | python |
Description
Presently, Python ports must include the following copy-pasta, to enable tests:
depends_test-append \ port:py${python.version}-pytest test.run yes test.cmd py.test-${python.branch} test.target test.env-append PYTHONPATH=${worksrcpath}/build/lib
So, it might make sense to add opt-in support for testing to the Python portgroup, to eliminate duplication of the above.
Proposed option, to enable opt-in: python.tests
(default to no)
Of note, it's understood that some Python ports require additional test-specific dependencies, beyond just py-test
. And this enhancement won't eliminate that.
However, it would still reduce portfile copy-pasta, and allow us to further simplify our Python ports.
Change History (3)
comment:1 follow-up: 2 Changed 3 years ago by reneeotten (Renee Otten)
comment:2 Changed 3 years ago by mascguy (Christopher Nielsen)
Replying to reneeotten:
I like that idea and it's certainly worth considering to add something along these lines as it would indeed simplify the ports. I'd probably in favor of having
python.tests
with options likepytest
ornose
to specify which testing framework to use. Ideally one would be able to check whethersupported_archs noarch
is set which would give the code you give above, if it's not set one would usepre-test { test.env PYTHONPATH=[glob -nocomplain ${worksrcpath}/build/lib*] }instead of the
test.env-append
given above. I haven't looked whether that's an easy thing to do, but we can investigate that a bit more.
Sounds great Renee. And I'm happy to do the work on this; just wanted to facilitate collaborative discussion, to ensure the various bases are covered.
I'll take a stab at all of this over the next week or two. Once the work is reasonably complete, I'll submit a PR for formal review.
And thanks as always for your feedback and insights!
comment:3 Changed 2 years ago by reneeotten (Renee Otten)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I like that idea and it's certainly worth considering to add something along these lines as it would indeed simplify the ports. I'd probably in favor of having
python.tests
with options likepytest
ornose
to specify which testing framework to use. Ideally one would be able to check whethersupported_archs noarch
is set which would give the code you give above, if it's not set one would useinstead of the
test.env-append
given above. I haven't looked whether that's an easy thing to do, but we can investigate that a bit more. I can take a look if you want, but that's probably not going to happen until Christmas time.