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 <[email protected]>
Reviewed-by: Alexander von Gluck <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Kacper Kasper
2026-01-24 20:39:20 +00:00
committed by Alexander von Gluck
parent d52ea5c8d2
commit ccbb6eb32d
7 changed files with 53 additions and 44 deletions
+37
View File
@@ -37,6 +37,42 @@ rule UnitTestLib
SharedLibrary $(lib) : $(sources) : $(libraries) libcppunit.so ;
UnitTestDependency $(lib) ;
UNIT_TEST_LIBRARIES on unittests += $(lib) ;
}
rule UnitTestResource
{
# UnitTestResource <target> : <source> : <flags> ;
#
# <flags> 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 <files> : <sourceDir> : <flags> ;
#
# <flags> 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) ;
}
+7 -4
View File
@@ -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 ;
@@ -53,7 +53,7 @@ exec(const std::vector<std::string>& args)
std::string
TestFilePath(const std::string& relativePath)
{
return relativePath;
return "resources/" + relativePath;
}
} // namespace
+1 -1
View File
@@ -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;
}
+3 -17
View File
@@ -4,20 +4,6 @@ UsePrivateHeaders netservices private shared ;
AddSubDirSupportedPlatforms libbe_test ;
rule CopyScript # cloned CopyBAppTestApp
{
# CopyScript <target> : <source> ;
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 <tests!unittests>proxy.py : proxy.py ;
CopyScript <tests!unittests>testserver.py : testserver.py ;
CopyScript <tests!unittests>testfile.txt : testfile.txt ;
UnitTestResources proxy.py testserver.py : : isExec ;
UnitTestResources testfile.txt ;
+1 -1
View File
@@ -49,7 +49,7 @@ void exec(const std::vector<std::string>& 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;
}
}
+3 -20
View File
@@ -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 ;