From ccbb6eb32dcde8eaf9880a17b04dd33c4e5f9c7f Mon Sep 17 00:00:00 2001 From: Kacper Kasper Date: Fri, 23 Jan 2026 21:13:38 +0100 Subject: [PATCH] haiku_unittests.hpkg: fix unittests dependency * Add rules for files required for tests execution. Change-Id: I2954f5dbec07af51ccdc9fd3389d530cf47ec0fd Reviewed-on: https://review.haiku-os.org/c/haiku/+/10265 Haiku-Format: Haiku-format Bot Reviewed-by: Alexander von Gluck Tested-by: Commit checker robot --- build/jam/TestsRules | 37 +++++++++++++++++++ build/jam/packages/HaikuUnitTests | 11 ++++-- .../kits/net/netservices2/TestServer.cpp | 2 +- src/tests/kits/net/service/HttpTest.cpp | 2 +- src/tests/kits/net/service/Jamfile | 20 ++-------- src/tests/kits/net/service/TestServer.cpp | 2 +- src/tests/kits/storage/Jamfile | 23 ++---------- 7 files changed, 53 insertions(+), 44 deletions(-) diff --git a/build/jam/TestsRules b/build/jam/TestsRules index 251e116edf..3c4da5cb2a 100644 --- a/build/jam/TestsRules +++ b/build/jam/TestsRules @@ -37,6 +37,42 @@ rule UnitTestLib SharedLibrary $(lib) : $(sources) : $(libraries) libcppunit.so ; UnitTestDependency $(lib) ; + UNIT_TEST_LIBRARIES on unittests += $(lib) ; +} + + +rule UnitTestResource +{ + # UnitTestResource : : ; + # + # supported values: isExec + local target = $(1:G=tests!unittests!resources) ; + local source = $(2) ; + local flags = $(3) ; + + MakeLocate $(target) : [ FDirName $(TARGET_UNIT_TEST_DIR) resources ] ; + File $(target) : $(source) ; + if isExec in $(flags) { + MODE on $(target) = $(EXEMODE) ; + } + MimeSet $(target) ; + UnitTestDependency $(target) ; + UNIT_TEST_RESOURCES on unittests += $(target) ; +} + + +rule UnitTestResources +{ + # UnitTestResources : : ; + # + # supports same values as UnitTestResource + local files = $(1) ; + local sourceDir = $(2) ; + local flags = $(3) ; + for file in $(files) { + LOCATE on $(file) = $(sourceDir) ; + UnitTestResource $(file:G=tests!unittests!resources) : $(file) : $(flags) ; + } } @@ -67,6 +103,7 @@ rule UnitTest : $(resources) ; UnitTestDependency $(target) ; + UNIT_TEST_EXECUTABLES on unittests += $(target) ; } diff --git a/build/jam/packages/HaikuUnitTests b/build/jam/packages/HaikuUnitTests index 6a01a136c0..1c23499fd4 100644 --- a/build/jam/packages/HaikuUnitTests +++ b/build/jam/packages/HaikuUnitTests @@ -1,9 +1,12 @@ local haikuUnitTestsPackage = haiku_unittests.hpkg ; HaikuPackage $(haikuUnitTestsPackage) ; -CopyDirectoryToPackage add-ons - : - $(TARGET_UNIT_TEST_DIR) -; +local libraries = [ on unittests return $(UNIT_TEST_LIBRARIES) ] ; +local executables = [ on unittests return $(UNIT_TEST_EXECUTABLES) ] ; +local resources = [ on unittests return $(UNIT_TEST_RESOURCES) ] ; + +AddFilesToPackage add-ons unittests lib : $(libraries) ; +AddFilesToPackage add-ons unittests resources : $(resources) ; +AddFilesToPackage add-ons unittests : $(executables) ; BuildHaikuPackage $(haikuUnitTestsPackage) : haiku_unittests ; diff --git a/src/tests/kits/net/netservices2/TestServer.cpp b/src/tests/kits/net/netservices2/TestServer.cpp index 8c14c75dd1..8166889096 100644 --- a/src/tests/kits/net/netservices2/TestServer.cpp +++ b/src/tests/kits/net/netservices2/TestServer.cpp @@ -53,7 +53,7 @@ exec(const std::vector& args) std::string TestFilePath(const std::string& relativePath) { - return relativePath; + return "resources/" + relativePath; } } // namespace diff --git a/src/tests/kits/net/service/HttpTest.cpp b/src/tests/kits/net/service/HttpTest.cpp index 9c1fdb0f2d..0727e3afd5 100644 --- a/src/tests/kits/net/service/HttpTest.cpp +++ b/src/tests/kits/net/service/HttpTest.cpp @@ -155,7 +155,7 @@ void SendAuthenticatedRequest( // Return the path of a file path relative to this source file. std::string TestFilePath(const std::string& relativePath) { - return relativePath; + return "resources/" + relativePath; } diff --git a/src/tests/kits/net/service/Jamfile b/src/tests/kits/net/service/Jamfile index 529a7cce5c..ebe6a945de 100644 --- a/src/tests/kits/net/service/Jamfile +++ b/src/tests/kits/net/service/Jamfile @@ -4,20 +4,6 @@ UsePrivateHeaders netservices private shared ; AddSubDirSupportedPlatforms libbe_test ; -rule CopyScript # cloned CopyBAppTestApp -{ - # CopyScript : ; - local target = $(1) ; - local source = $(2) ; - - MakeLocate $(target) : $(TARGET_UNIT_TEST_DIR) ; - File $(target) : $(source) ; - MODE on $(target) = $(EXEMODE) ; - MimeSet $(target) ; - - UnitTestDependency $(target) ; -} - UnitTestLib servicekittest.so : ServiceKitTestAddon.cpp @@ -32,6 +18,6 @@ UnitTestLib servicekittest.so : : be libnetservices.a shared $(TARGET_NETWORK_LIBS) $(HAIKU_NETAPI_LIB) [ TargetLibstdc++ ] ; -CopyScript proxy.py : proxy.py ; -CopyScript testserver.py : testserver.py ; -CopyScript testfile.txt : testfile.txt ; + +UnitTestResources proxy.py testserver.py : : isExec ; +UnitTestResources testfile.txt ; diff --git a/src/tests/kits/net/service/TestServer.cpp b/src/tests/kits/net/service/TestServer.cpp index b993d15ba8..842fff2d1f 100644 --- a/src/tests/kits/net/service/TestServer.cpp +++ b/src/tests/kits/net/service/TestServer.cpp @@ -49,7 +49,7 @@ void exec(const std::vector& args) // Return the path of a file path relative to this source file. std::string TestFilePath(const std::string& relativePath) { - return relativePath; + return "resources/" + relativePath; } } diff --git a/src/tests/kits/storage/Jamfile b/src/tests/kits/storage/Jamfile index af33ce2b07..8d24092b8c 100644 --- a/src/tests/kits/storage/Jamfile +++ b/src/tests/kits/storage/Jamfile @@ -28,28 +28,11 @@ UnitTestLib libstoragetest.so : be [ TargetLibstdc++ ] ; -rule CopyResources { - local files = $(1) ; - local sourceDir = $(2) ; - local targetDir = $(3) ; - for file in $(files) { - LOCATE on $(file) = $(sourceDir) ; - local targetFile = $(file:G=tests!unittests) ; - MakeLocate $(targetFile) : [ FDirName $(TARGET_UNIT_TEST_DIR) $(targetDir) ] ; - File $(targetFile) : $(file) ; - MODE on $(targetFile) = $(EXEMODE) ; - MimeSet $(targetFile) ; - } -} - # To run the tests some test files must be around. { - local sourceDir = src tests kits storage resources ; - local files = elf elf-no-res pef pef-no-res ppc.rsrc x86.rsrc ; - local sourceDirName = [ FDirName $(HAIKU_TOP) $(sourceDir) ] ; - local grist = [ FGrist $(sourceDir) ] ; - CopyResources $(files:G=$(grist)) : $(sourceDirName) : resources ; - Depends libstoragetest.so : $(files:G=tests!unittests) ; + local sourceDir = [ FDirName $(HAIKU_TOP) src tests kits storage resources ] ; + UnitTestResources elf elf-no-res pef pef-no-res : $(sourceDir) : isExec ; + UnitTestResources ppc.rsrc x86.rsrc : $(sourceDir) ; } SubInclude HAIKU_TOP src tests kits storage disk_device ;