Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / PythonTest.mk
blob16bc7d2404a786dd028ef9991c620d5f5956957c
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # PythonTest class
12 gb_PythonTest_UNITTESTFAILED ?= $(GBUILDDIR)/platform/unittest-failed-default.sh
14 ifeq ($(SYSTEM_PYTHON),)
15 gb_PythonTest_EXECUTABLE := $(gb_Python_INSTALLED_EXECUTABLE)
16 gb_PythonTest_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE_GDB)
17 gb_PythonTest_DEPS ?= $(call gb_Package_get_target,python3) $(call gb_Package_get_target,python_shell)
18 else
19 gb_PythonTest_EXECUTABLE := $(PYTHON_FOR_BUILD)
20 gb_PythonTest_EXECUTABLE_GDB := $(PYTHON_FOR_BUILD)
21 gb_PythonTest_DEPS :=
22 endif
24 gb_PythonTest_COMMAND := $(gb_PythonTest_EXECUTABLE) -m org.libreoffice.unittest
26 .PHONY : $(call gb_PythonTest_get_clean_target,%)
27 $(call gb_PythonTest_get_clean_target,%) :
28 $(call gb_Helper_abbreviate_dirs,\
29 rm -fr $(WORKDIR)/PythonTest/$*)
31 ifneq ($(DISABLE_PYTHON),TRUE)
33 .PHONY : $(call gb_PythonTest_get_target,%)
34 $(call gb_PythonTest_get_target,%) :\
35 $(call gb_Library_get_target,pyuno) \
36 $(if $(filter-out WNT,$(OS)),$(call gb_Library_get_target,pyuno_wrapper)) \
37 | $(gb_PythonTest_DEPS)
38 ifneq ($(gb_SUPPRESS_TESTS),)
39 @true
40 else
41 $(call gb_Output_announce,$*,$(true),PYT,2)
42 $(call gb_Helper_abbreviate_dirs,\
43 rm -rf $(dir $(call gb_PythonTest_get_target,$*)) && \
44 mkdir -p $(dir $(call gb_PythonTest_get_target,$*))user/user/autotext && \
45 $(if $(gb_CppunitTest__interactive),, \
46 $(if $(value gb_CppunitTest_postprocess), \
47 rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
48 ($(gb_PythonTest_PRECOMMAND) \
49 $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
50 $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
51 $(DEFS) \
52 TEST_LIB=$(call gb_Library_get_target,test) \
53 URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
54 PYTHONPATH="$(PYPATH)" \
55 UserInstallation=$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*))user) \
56 TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
57 PYTHONDONTWRITEBYTECODE=1 \
58 $(gb_TEST_ENV_VARS) \
59 $(gb_CppunitTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_RR) \
60 $(gb_PythonTest_COMMAND) \
61 $(if $(PYTHON_TEST_NAME),$(PYTHON_TEST_NAME),$(MODULES)) \
62 $(if $(gb_CppunitTest__interactive),, \
63 > $@.log 2>&1 \
64 || ($(if $(value gb_CppunitTest_postprocess), \
65 RET=$$?; \
66 $(call gb_CppunitTest_postprocess,$(gb_PythonTest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
67 cat $@.log; $(gb_PythonTest_UNITTESTFAILED) Python $*))))
68 endif
70 # always use udkapi and URE services
71 define gb_PythonTest_PythonTest
72 $(call gb_PythonTest_get_target,$(1)) : PYPATH := $(SRCDIR)/unotest/source/python$$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_PYUNO_FOLDER)$(if $(filter-out $(LIBO_LIB_PYUNO_FOLDER),$(LIBO_LIB_FOLDER)),$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_FOLDER))
73 $(call gb_PythonTest_get_target,$(1)) : MODULES :=
75 $(eval $(call gb_Module_register_target,PythonTest_$(1),$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
76 $(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
78 endef
80 define gb_PythonTest_set_defs
81 $(call gb_PythonTest_get_target,$(1)) : DEFS := $(2)
83 endef
85 # put the directory on the PYTHONPATH because the "unittest" loader
86 # mysteriously fails to load modules given as absolute path unless the $PWD is
87 # a prefix of the absolute path, which it is not when we go into a certain
88 # dir to get a core dump there
90 # gb_PythonTest_add_modules directory module(s)
91 define gb_PythonTest_add_modules
92 $(call gb_PythonTest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(2)
93 $(call gb_PythonTest_get_target,$(1)) : MODULES += $(3)
95 endef
97 define gb_PythonTest_use_customtarget
98 $(call gb_PythonTest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
100 endef
102 gb_PythonTest_use_more_fonts = $(call gb_TestHelpers_use_more_fonts,$(call gb_PythonTest_get_target,$(1)))
104 else # DISABLE_PYTHON
106 .PHONY : $(call gb_PythonTest_get_target,$(1))
107 $(call gb_PythonTest_get_target,%) :
108 ifeq ($(gb_SUPPRESS_TESTS),)
109 $(call gb_Output_announce,$* (skipped - no PythonTest),$(true),PYT,2)
110 endif
111 @true
113 define gb_PythonTest_PythonTest
114 $(eval $(call gb_Module_register_target,PythonTest_$(1),$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
115 $(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
117 endef
119 gb_PythonTest_set_defs :=
120 gb_PythonTest_add_modules :=
121 gb_PythonTest_use_customtarget :=
123 endif # DISABLE_PYTHON
124 # vim: set noet sw=4: