1 2# unit test pseudo target 3NotFile unittests ; 4 5rule UnitTestLib 6{ 7 # UnitTestLib <lib> : <sources> : <libraries> ; 8 # 9 local lib = $(1) ; 10 local sources = $(2) ; 11 local libraries = $(3) ; 12 13 # if TEST_DEBUG is defined, we turn on debugging 14 if $(TEST_DEBUG) { 15 DEBUG on $(lib) [ FGristFiles $(sources:S=$(SUFOBJ)) ] ?= 1 ; 16 } 17 18 # define TEST_R5/TEST_HAIKU depending on the platform we build for 19 if $(TARGET_PLATFORM) = libbe_test { 20 ObjectDefines $(2) : TEST_HAIKU TEST_OBOS ; 21 22 # make the target depend on the installed libbe libraries 23 Depends $(lib) : 24 <tests!unittests>libbe_test.so ; 25 } else { 26 ObjectDefines $(2) : TEST_R5 ; 27 } 28 29 UseCppUnitObjectHeaders $(sources) ; 30 31 MakeLocate $(lib) : $(TARGET_UNIT_TEST_LIB_DIR) ; 32 SharedLibrary $(lib) : $(sources) : $(libraries) libcppunit.so ; 33 34 Depends unittests : $(lib) ; 35} 36 37rule UnitTest 38{ 39 # UnitTest <target> : <sources> : <libraries> : <resources> ; 40 # 41 local target = $(1) ; 42 local sources = $(2) ; 43 local libraries = $(3) ; 44 local resources = $(4) ; 45 46 # define TEST_R5/TEST_HAIKU depending on the platform we build for 47 if $(TARGET_PLATFORM) = libbe_test { 48 ObjectDefines $(2) : TEST_HAIKU TEST_OBOS ; 49 50 # make the target depend on the installed libbe libraries 51 Depends $(target) : 52 <tests!unittests>libbe_test.so ; 53 } else { 54 ObjectDefines $(2) : TEST_R5 ; 55 } 56 57 UseCppUnitObjectHeaders $(sources) ; 58 59 MakeLocate $(target) : $(TARGET_UNIT_TEST_DIR) ; 60 SimpleTest $(target) : $(sources) : $(libraries) libcppunit.so 61 : $(resources) ; 62 63 Depends unittests : $(lib) ; 64} 65 66rule TestObjects 67{ 68 # TestObjects <sources> ; 69 # 70 local sources = $(1) ; 71 72 # define TEST_R5/TEST_HAIKU depending on the platform we build for 73 if $(TARGET_PLATFORM) = libbe_test { 74 ObjectDefines $(2) : TEST_HAIKU TEST_OBOS ; 75 } else { 76 ObjectDefines $(2) : TEST_R5 ; 77 } 78 79 UseCppUnitObjectHeaders $(sources) ; 80 81 Objects $(sources) ; 82} 83 84rule SimpleTest 85{ 86 # SimpleTest <target> : <sources> : [ <libraries> ] : [ <resources> ] ; 87 88 # if TEST_DEBUG is defined, we turn on debugging 89 if $(TEST_DEBUG) { 90 DEBUG on $(1) [ FGristFiles $(2:S=$(SUFOBJ)) ] ?= 1 ; 91 } 92 93 Executable $(1) : $(2) : $(3) : $(4) ; 94} 95 96rule BuildPlatformTest 97{ 98 # Usage BuildPlatformTest <target> : <sources> ; 99 local target = $(1) ; 100 local sources = $(2) ; 101 102 local relPath ; 103 if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 104 relPath = $(SUBDIR_TOKENS[3-]) ; 105 } else { 106 relPath = $(SUBDIR_TOKENS[2-]) ; 107 } 108 MakeLocate $(target) : [ FDirName $(HAIKU_TEST_DIR) $(relPath) ] ; 109 110 BuildPlatformMain $(target) : $(sources) ; 111} 112