Hi After a massive amount of time and effort, I've managed to get about 70% of directories with CppUnit tests converted to Google Test, gotten them to compile and link, gotten most tests to pass, and gotten some of those that pass running during the build.
For the remaining tests, we need to get Google Test running in gbuild, as it was only integrated into dmake (as per https://wiki.openoffice.org/wiki/Googletest). With tremendous effort (is anything in AOO easy?) I managed to come up with a patch for this, but can only verify it works on my setup (FreeBSD), it still needs testing on Linux, Solaris, Windows, MingW, OS/2 (lol) and MacOS. Can our buildbots test patches that are not yet committed? If not, I would appreciate it if some volunteers can apply the attached patch, do a clean build on those platforms, and report whether it worked. If it breaks it should do so in main/sfx2; please run make in that directory and attach the output. Thank you Damjan
Index: solenv/gbuild/GoogleTest.mk =================================================================== --- solenv/gbuild/GoogleTest.mk (revision 0) +++ solenv/gbuild/GoogleTest.mk (working copy) @@ -0,0 +1,92 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + + + + +# GoogleTest class + +# in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell +DBGSV_ERROR_OUT := shell +export DBGSV_ERROR_OUT + +# defined by platform +# gb_CppunitTest_TARGETTYPE +# gb_CppunitTest_get_filename +gb_GoogleTest__get_linktargetname = GoogleTest/$(call gb_GoogleTest_get_filename,$(1)) + +.PHONY : $(call gb_GoogleTest_get_clean_target,%) +$(call gb_GoogleTest_get_clean_target,%) : + $(call gb_Helper_abbreviate_dirs,\ + rm -f $(call gb_GoogleTest_get_target,$*) $(call gb_GoogleTest_get_target,$*).xml) + +.PHONY : $(call gb_GoogleTest_get_target,%) +$(call gb_GoogleTest_get_target,%) : + $(call gb_Output_announce,$*,$(true),CUT,2) + $(call gb_Helper_abbreviate_dirs_native,\ + mkdir -p $(dir $@) && \ + $(gb_GoogleTest_GTESTPRECOMMAND) $(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$*)) \ + --gtest_output="xml:$(call gb_GoogleTest_get_target,$*).xml") + +define gb_GoogleTest_GoogleTest +$(call gb_GoogleTest__GoogleTest_impl,$(1),$(call gb_GoogleTest__get_linktargetname,$(1))) +endef + +define gb_GoogleTest__GoogleTest_impl +$(call gb_LinkTarget_LinkTarget,$(2)) +$(call gb_LinkTarget_set_targettype,$(2),GoogleTest) +$(call gb_LinkTarget_add_linked_libs,$(2),gtest) +$(call gb_GoogleTest_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2)) +$(call gb_GoogleTest_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2)) +$(call gb_GoogleTest_GoogleTest_platform,$(1),$(2),$(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$(1)))) +$$(eval $$(call gb_Module_register_target,$(call gb_GoogleTest_get_target,$(1)),$(call gb_GoogleTest_get_clean_target,$(1)))) +endef + +define gb_GoogleTest__forward_to_Linktarget +gb_GoogleTest_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_GoogleTest__get_linktargetname,$$(1)),$$(2),$$(3)) +endef + +$(eval $(foreach method,\ + add_cobject \ + add_cobjects \ + add_cxxobject \ + add_cxxobjects \ + add_objcxxobject \ + add_objcxxobjects \ + add_exception_objects \ + add_noexception_objects \ + set_cflags \ + set_cxxflags \ + set_objcxxflags \ + set_defs \ + set_include \ + set_ldflags \ + set_library_path_flags \ + add_linked_libs \ + add_linked_static_libs \ + add_package_headers \ + add_sdi_headers \ + add_precompiled_header \ +,\ + $(call gb_GoogleTest__forward_to_Linktarget,$(method))\ +)) + +# vim: set noet sw=4 ts=4: Index: solenv/gbuild/TargetLocations.mk =================================================================== --- solenv/gbuild/TargetLocations.mk (revision 1701411) +++ solenv/gbuild/TargetLocations.mk (working copy) @@ -52,6 +52,7 @@ gb_GenCxxObject_get_target = $(WORKDIR)/GenCxxObject/$(1).o gb_Executable_get_external_headers_target = $(WORKDIR)/ExternalHeaders/Executable/$(1) gb_Executable_get_headers_target = $(WORKDIR)/Headers/Executable/$(1) +gb_GoogleTest_get_target = $(WORKDIR)/GoogleTest/$(1).test gb_JavaClassSet_get_classdir = $(WORKDIR)/JavaClassSet/$(1) gb_JavaClassSet_get_repo_target = $(WORKDIR)/JavaClassSet/$(2)/$(1).done gb_JavaClassSet_get_target = $(WORKDIR)/JavaClassSet/$(1)/done @@ -110,6 +111,7 @@ SdiTarget \ SrsTarget \ CppunitTest \ + GoogleTest \ CustomTarget \ )) Index: solenv/gbuild/gbuild.mk =================================================================== --- solenv/gbuild/gbuild.mk (revision 1701411) +++ solenv/gbuild/gbuild.mk (working copy) @@ -237,6 +237,7 @@ CustomTarget \ PrecompiledHeaders \ CppunitTest \ + GoogleTest \ JavaClassSet \ JunitTest \ Module \ Index: solenv/gbuild/platform/freebsd.mk =================================================================== --- solenv/gbuild/platform/freebsd.mk (revision 1701411) +++ solenv/gbuild/platform/freebsd.mk (working copy) @@ -268,7 +268,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) +$(if $(filter Library CppunitTest GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) endef @@ -380,6 +380,15 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +$(call gb_LinkTarget_get_target,$(2)) : RPATH := -Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib Index: solenv/gbuild/platform/linux.mk =================================================================== --- solenv/gbuild/platform/linux.mk (revision 1701411) +++ solenv/gbuild/platform/linux.mk (working copy) @@ -245,7 +245,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) +$(if $(filter Library CppunitTest GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) endef @@ -357,6 +357,15 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +$(call gb_LinkTarget_get_target,$(2)) : RPATH := -Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib Index: solenv/gbuild/platform/macosx.mk =================================================================== --- solenv/gbuild/platform/macosx.mk (revision 1701411) +++ solenv/gbuild/platform/macosx.mk (working copy) @@ -300,7 +300,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2))) +$(if $(filter Library CppunitTest GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) endef @@ -402,6 +402,15 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +$(call gb_LinkTarget_get_target,$(2)) : RPATH := +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib Index: solenv/gbuild/platform/os2.mk =================================================================== --- solenv/gbuild/platform/os2.mk (revision 1701411) +++ solenv/gbuild/platform/os2.mk (working copy) @@ -347,7 +347,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2))) +$(if $(filter GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2))) $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlinklibrary,$(1))) endef @@ -507,6 +507,15 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +$(call gb_LinkTarget_get_target,$(2)) : +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := Index: solenv/gbuild/platform/solaris.mk =================================================================== --- solenv/gbuild/platform/solaris.mk (revision 1701411) +++ solenv/gbuild/platform/solaris.mk (working copy) @@ -221,7 +221,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) +$(if $(filter Library CppunitTest GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) endef @@ -335,6 +335,15 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +$(call gb_LinkTarget_get_target,$(2)) : RPATH := -Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib Index: solenv/gbuild/platform/windows.mk =================================================================== --- solenv/gbuild/platform/windows.mk (revision 1701411) +++ solenv/gbuild/platform/windows.mk (working copy) @@ -420,7 +420,7 @@ $(gb_LINK) \ $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ $(if $(filter StaticLibrary,$(TARGETTYPE)),$(gb_StaticLibrary_TARGETTYPEFLAGS)) \ - $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ + $(if $(filter GoogleTest Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ $(LDFLAGS) \ @$${RESPONSEFILE} \ $(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))) \ @@ -613,6 +613,14 @@ endef +# GoogleTest class + +gb_GoogleTest_GTESTPRECOMMAND := +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := Index: solenv/gbuild/platform/winmingw.mk =================================================================== --- solenv/gbuild/platform/winmingw.mk (revision 1701411) +++ solenv/gbuild/platform/winmingw.mk (working copy) @@ -448,7 +448,7 @@ define gb_LinkTarget__command $(call gb_Output_announce,$(2),$(true),LNK,4) -$(if $(filter Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2))) +$(if $(filter GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2))) $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinklibrary,$(1),$(2))) $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlinklibrary,$(1))) endef @@ -594,7 +594,14 @@ gb_Executable_get_rpath := gb_Executable_Executable_platform = +# GoogleTest class +gb_GoogleTest_GTESTPRECOMMAND := +gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) + +define gb_GoogleTest_GoogleTest_platform +endef + # CppunitTest class gb_CppunitTest_CPPTESTPRECOMMAND := Index: sfx2/GoogleTest_sfx2_metadatable.mk =================================================================== --- sfx2/GoogleTest_sfx2_metadatable.mk (revision 0) +++ sfx2/GoogleTest_sfx2_metadatable.mk (working copy) @@ -0,0 +1,48 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + + + +$(eval $(call gb_GoogleTest_GoogleTest,sfx2_metadatable)) + +$(eval $(call gb_GoogleTest_add_exception_objects,sfx2_metadatable, \ + sfx2/qa/cppunit/test_metadatable \ +)) + +$(eval $(call gb_GoogleTest_add_linked_libs,sfx2_metadatable, \ + sal \ + sfx \ + stl \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_GoogleTest_set_include,sfx2_metadatable,\ + $$(INCLUDE) \ + -I$(OUTDIR)/inc/offuh \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_GoogleTest_set_ldflags,sfx2_metadatable,\ + $$(LDFLAGS) \ + -lgtest \ +)) + +# vim: set noet sw=4 ts=4: Index: sfx2/Module_sfx2.mk =================================================================== --- sfx2/Module_sfx2.mk (revision 1701411) +++ sfx2/Module_sfx2.mk (working copy) @@ -30,9 +30,9 @@ Package_sdi \ )) -ifeq ($(WITH_CPPUNIT),YES) +ifeq ($(ENABLE_UNIT_TESTS),YES) $(eval $(call gb_Module_add_check_targets,sfx2,\ - CppunitTest_sfx2_metadatable \ + GoogleTest_sfx2_metadatable \ )) endif
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org For additional commands, e-mail: dev-h...@openoffice.apache.org