[MacPorts] #64045: py-pyzstd: tests fail from clean state because glob is used in global part of portfile
MacPorts
noreply at macports.org
Tue Nov 23 17:31:15 UTC 2021
#64045: py-pyzstd: tests fail from clean state because glob is used in global part
of portfile
-------------------------+----------------------
Reporter: ryandesign | Owner: catap
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version:
Resolution: | Keywords:
Port: py-pyzstd |
-------------------------+----------------------
Description changed by ryandesign:
Old description:
> py-pyzstd does:
>
> {{{
> test.env PYTHONPATH=[glob -nocomplain
> ${worksrcpath}/build/lib*]
> }}}
>
> This won't work if the port is in a clean state at the time the portfile
> is parsed because ${worksrcpath} and its contents don't exist yet.
>
> For example: `sudo port clean py39-pyzstd && sudo port test py39-pyzstd`
> fails:
>
> {{{
> :info:test test_zstd (unittest.loader._FailedTest) ... ERROR
> :info:test
> ======================================================================
> :info:test ERROR: test_zstd (unittest.loader._FailedTest)
> :info:test
> ----------------------------------------------------------------------
> :info:test ImportError: Failed to import test module: test_zstd
> :info:test Traceback (most recent call last):
> :info:test File
> "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py",
> line 154, in loadTestsFromName
> :info:test module = __import__(module_name)
> :info:test File "/opt/local/var/macports/build
> /_Users_rschmidt_macports_macports-ports-ryandesign-fork_python_py-
> pyzstd/py39-pyzstd/work/pyzstd-0.15.0/tests/test_zstd.py", line 20, in
> <module>
> :info:test import pyzstd
> :info:test ModuleNotFoundError: No module named 'pyzstd'
> :info:test
> ----------------------------------------------------------------------
> }}}
>
> A subsequent `sudo port test py39-pyzstd` without cleaning first
> succeeds.
>
> To avoid this problem, if you need to `glob` or otherwise inspect the
> contents of ${worksrcpath}, you can't do it in the global part of the
> portfile. You have to defer it to a time when ${worksrcpath} exists. In
> this case, you should enclose at least the `test.env` line in a `pre-
> test` block.
New description:
py-pyzstd does:
{{{
test.env PYTHONPATH=[glob -nocomplain
${worksrcpath}/build/lib*]
}}}
This won't work if the port is in a clean state at the time the portfile
is parsed because ${worksrcpath} and its contents don't exist yet.
For example: `sudo port clean py39-pyzstd && sudo port test py39-pyzstd`
fails because `PYTHONPATH` is empty:
{{{
:debug:test Environment:
}}}
{{{
:debug:test PYTHONPATH=''
}}}
{{{
:info:test test_zstd (unittest.loader._FailedTest) ... ERROR
:info:test
======================================================================
:info:test ERROR: test_zstd (unittest.loader._FailedTest)
:info:test
----------------------------------------------------------------------
:info:test ImportError: Failed to import test module: test_zstd
:info:test Traceback (most recent call last):
:info:test File
"/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py",
line 154, in loadTestsFromName
:info:test module = __import__(module_name)
:info:test File "/opt/local/var/macports/build
/_Users_rschmidt_macports_macports-ports-ryandesign-fork_python_py-
pyzstd/py39-pyzstd/work/pyzstd-0.15.0/tests/test_zstd.py", line 20, in
<module>
:info:test import pyzstd
:info:test ModuleNotFoundError: No module named 'pyzstd'
:info:test
----------------------------------------------------------------------
}}}
A subsequent `sudo port test py39-pyzstd` without cleaning first succeeds.
To avoid this problem, if you need to `glob` or otherwise inspect the
contents of ${worksrcpath}, you can't do it in the global part of the
portfile. You have to defer it to a time when ${worksrcpath} exists. In
this case, you should enclose at least the `test.env` line in a `pre-test`
block.
--
--
Ticket URL: <https://trac.macports.org/ticket/64045#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list