changing 'configure' options for testing

Ken Cunningham ken.cunningham.webuse at gmail.com
Tue Sep 28 15:13:21 UTC 2021


On 2021-09-28 7:44 a.m., Daniel J. Luke wrote:
> On Sep 20, 2021, at 10:20 AM, Daniel J. Luke <dluke at geeklair.net> wrote:
>> On Sep 20, 2021, at 8:15 AM, Frank Dean <frank at fdsd.co.uk> wrote:
>>> Daniel J. Luke <dluke at geeklair.net> writes:
>>>> The newest version of clamav uses cmake for builds. In the 'configure' stage, I have it disabling tests because otherwise it won't build without the test dependencies installed (check and pytest).
>>>>
>>>> Do we have a template or example of a canonical way to handle this? I don't see an obvious hook for when someone is running `port test` to change configure.args (I could, of course, add a post-extract/pre-configure and do some non-declaritive test to see if `port test` is being run and use that to branch - but that feels like a bad design choice).
>>> The rapidjson port implements a 'tests' variant to handle a similar
>>> situation.  I used the same pattern for the libosmium port.  The tests
>>> can then be run with `sudo port -d test current +tests`.
>> That works, I guess.
>>
>> Is there interest in having base auto-add +tests if `port test` is called? (I haven't looked at base/ code in a while, but it seems possible). I like to imagine a future where we have enough infrastructure that we would run `port test` for any ports that have test.run set.
> On this same train of thought - clamav tests run against the installed libraries (like some other ports tend to do) - in long-ago times I'd solve this by setting DYLD_LIBRARY_PATH - but since SIP started removing these that no longer works normally. I think trace mode has a(n elaborate) workaround where it copies binaries and executes the copies, but that doesn't seem like something I should implement in a portfile ;-) [This is another instance where if trace mode were the default, things would 'just work']
>
> Has anyone else already solved this?


The way our cmake PortGroup sets things up, running tests is harder. You 
can configure cmake to allow testing to find the libraries in the build 
tree. See for example what I did in libcbor:


variant tests description {enable tests} {
     depends_test-append         port:cmocka
     configure.args-append       -DWITH_TESTS=ON
     configure.pre_args-replace -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
     test.run            yes
     test.target         test
}

Ken






>


More information about the macports-dev mailing list