.include <bsd.init.mk>

.PATH:	${GOOGLETEST_SRCROOT}/src ${GOOGLETEST_SRCROOT}/test

GTESTS+=	gtest_premature_exit_test
# These test scenarios are't handled properly with the googletest engine in
# kyua 0.15.0.
PLAIN_TESTS_CXX+= gtest_environment_test
PLAIN_TESTS_CXX+= gtest_no_test_unittest
PLAIN_TESTS_CXX+= gtest_throw_on_failure_ex_test

# NOTE: these tests rely on testing by side-effect with global variables/state
# used in multiple testcases.
#
# Running this plain C++ tests gets around that problem.
PLAIN_TESTS_CXX+= googletest-param-test-test
PLAIN_TESTS_CXX+= gtest_repeat_test
PLAIN_TESTS_CXX+= gtest_stress_test
PLAIN_TESTS_CXX+= gtest-unittest-api_test

CXXFLAGS+=	-I${GOOGLETEST_SRCROOT}/include
CXXFLAGS+=	-I${GOOGLETEST_SRCROOT}

.for death_test in gtest-death-test_ex_catch_test gtest-death-test_ex_nocatch_test
# XXX: copying source files in order to tweak CXXFLAGS seems hacky.
${death_test}.cc: googletest-death-test_ex_test.cc
	${CP} ${.ALLSRC} ${.TARGET}
CLEANFILES+=	${death_test}.cc
CXXFLAGS.${death_test}+= -fexception
.endfor

CXXFLAGS.gtest-death-test_ex_catch_test+=	\
	-DGTEST_ENABLE_CATCH_EXCEPTIONS_=1

CXXFLAGS.gtest-death-test_ex_nocatch_test+=     \
	-DGTEST_ENABLE_CATCH_EXCEPTIONS_=0

SRCS.googletest-param-test-test=       \
	googletest-param-test-test.cc   \
	googletest-param-test2-test.cc

LIBADD+=	gtest

CXXFLAGS.clang+=	-Wno-error=missing-variable-declarations
MK_WERROR.gcc=		no

# XXX: explicitly listing -lpthread is incorrect. src.libnames.mk should be
#      handling this.
LIBADD.gtest_stress_test+=     pthread

.include <bsd.test.mk>
