freebsd / poudriere

Port/Package build and test system
https://github.com/freebsd/poudriere/wiki
BSD 2-Clause "Simplified" License
379 stars 161 forks source link

TEST_DEPENDS aren't taken from packages #1131

Open arrowd opened 4 months ago

arrowd commented 4 months ago

When Poudriere 3.4.1 installs {BUILD,LIB}_DEPENDS it passes USE_PACKAGE_DEPENDS_ONLY=1 to force using packages:

=======================<phase: lib-depends    >============================
===== env: DEVELOPER_MODE=yes USE_PACKAGE_DEPENDS_ONLY=1 USER=root UID=0 GID=0

Turns out this is not the case for TEST_DEPENDS during the package phase:

=======================<phase: package        >============================
===== env: DEVELOPER_MODE=yes PACKAGES=/tmp/pkgs PKGREPOSITORY=/tmp/pkgs PKGLATESTREPOSITORY=/tmp/pkgs/Latest 'PKG_NOTES=build_timestamp built_by' 'PKG_NOTE_build_timestamp=2024-03-06T15:50:56+0000' 'PKG_NOTE_built_by=poudriere-git-3.4.1' STRICT_DEPENDS=yes USER=nobody UID=65534 GID=65534

This leads to

===>  Testing for libjxl-0.10.1
===>   libjxl-0.10.1 depends on package: googletest>0 - not found
===>   googletest-1.14.0 depends on file: /usr/local/sbin/pkg - found
=> google-googletest-v1.14.0_GH0.tar.gz doesn't seem to exist in /portdistfiles/.
=> /portdistfiles/ is not writable by you; cannot fetch.
*** Error code 1

The make test stage gets hooked into the package phase via Mk/Features/testing.mk that I've added recently.

I guess, this can easily be fixed by making Poudriere pass USE_PACKAGE_DEPENDS_ONLY=1 for the package phase?

bdrewery commented 4 months ago

I don't see how this could work without #355. The problem with Poudriere is not that it "simply does not run make test".

For what it's worth I plan to tackle this (#355) after I merge in #822 in the coming weeks.

arrowd commented 4 months ago

The test dependencies may not be built by the time make package runs. It is a dependency ordering problem which is why your package is missing.

No, my dependency is built by a previous poud bulk. Or even poudriere testport built it, I'll recheck this.

As for #355, I already implemented the hooking at the framework level via Mk/Features/testing.mk. The user defines WITH_TESTING=yes or WITH_TESTING_PORTS= some origins and then make test is run as part of make package.

So, in this case really just need USE_PACKAGE_DEPENDS_ONLY=1 to be passed by Poudriere.

arrowd commented 3 months ago

Yes, you're right, Poudriere also doesn't queue TEST_DEPENDS. But even just having USE_PACKAGE_DEPENDS_ONLY=1 passed already improves the situation a lot.

arrowd commented 3 months ago

Here' is a hack that fixed things for me: https://github.com/arrowd/poudriere/commit/7ac7541d82b905d214894cc509014b5a8e1c6f7d

mandree commented 2 months ago

@arrowd I see several packages failing to build because the test-depends aren't queued by poudriere-devel yet. And those fail because we do not - by default - permit builds to fetch anything (more precisely, to resolve DNS after the fetch stage)

arrowd commented 2 months ago

Yes, hacked it up a bit, see my previous comment. But this is either not an ideal solution and a more substantial work has to be done on the Poudriere side.

mandree commented 2 months ago

Before we had the bits in place we have this year, I used to hack my Makefiles with (edited:) BUILD_DEPENDS+=${TEST_DEPENDS} or something like that, depending on the port. This is somewhat blunt as well... but really lifts TEST_DEPENDS to BUILD_DEPENDS, which is what you need anyways to build a package if you use -DWITH_TESTING or WITH_TESTING_PORTS=category/portname, (edited:) because this way, testing is a prerequisite for packaging.

We can't currently separate build-deps from test-deps when building packages, or did I miss some recent development?

arrowd commented 2 months ago

This is actually an interesting idea! I will try to find time to play with it, thanks.

bdrewery commented 2 months ago

We can't currently separate build-deps from test-deps when building packages, or did I miss some recent development?

We can now after very recent changes. I need to put out a PoC for a proper TEST_DEPENDS/make test integration.

Edit: commit 48f74bfe888172311b4b25c64f807478df2ece2f