bump product version to 7.2.5.1
[LibreOffice.git] / solenv / gbuild / PythonTest.mk
blobbc404d4fb81702c8250c2bdc2e87e0616905deb8
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_GDBTRACE et al are defined alongside gb_CppunitTest_GDBTRACE in CppunitTest.mk)
14 gb_PythonTest_UNITTESTFAILED ?= $(GBUILDDIR)/platform/unittest-failed-default.sh
16 ifeq ($(SYSTEM_PYTHON),)
17 gb_PythonTest_EXECUTABLE := $(gb_Python_INSTALLED_EXECUTABLE)
18 gb_PythonTest_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE_GDB)
19 gb_PythonTest_DEPS ?= $(call gb_Package_get_target,python3) $(call gb_Package_get_target,python_shell)
20 else
21 gb_PythonTest_EXECUTABLE := $(PYTHON_FOR_BUILD)
22 gb_PythonTest_EXECUTABLE_GDB := $(PYTHON_FOR_BUILD)
23 gb_PythonTest_DEPS :=
24 endif
26 gb_PythonTest_COMMAND := $(gb_PythonTest_EXECUTABLE) -m org.libreoffice.unittest
28 .PHONY : $(call gb_PythonTest_get_clean_target,%)
29 $(call gb_PythonTest_get_clean_target,%) :
30 $(call gb_Helper_abbreviate_dirs,\
31 rm -fr $(WORKDIR)/PythonTest/$*)
33 ifneq ($(DISABLE_PYTHON),TRUE)
35 .PHONY : $(call gb_PythonTest_get_target,%)
36 $(call gb_PythonTest_get_target,%) :\
37 $(call gb_Library_get_target,pyuno) \
38 $(if $(filter-out WNT,$(OS)),$(call gb_Library_get_target,pyuno_wrapper)) \
39 | $(gb_PythonTest_DEPS)
40 ifneq ($(gb_SUPPRESS_TESTS),)
41 @true
42 else
43 $(call gb_Output_announce,$*,$(true),PYT,2)
44 $(call gb_Trace_StartRange,$*,PYT)
45 $(call gb_Helper_abbreviate_dirs,\
46 rm -rf $(dir $(call gb_PythonTest_get_target,$*)) && \
47 mkdir -p $(dir $(call gb_PythonTest_get_target,$*))user/user/autotext && \
48 $(if $(gb_CppunitTest__interactive),, \
49 $(if $(value gb_CppunitTest_postprocess), \
50 rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
51 { \
52 $(if $(gb_PythonTest_PREGDBTRACE),$(gb_PythonTest_PREGDBTRACE) &&) \
53 $(if $(filter gdb,$(gb_PythonTest_GDBTRACE)),,$(gb_PythonTest_PRECOMMAND)) \
54 $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
55 $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
56 $(DEFS) \
57 TEST_LIB=$(call gb_Library_get_target,test) \
58 URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
59 PYTHONPATH="$(PYPATH)" \
60 UserInstallation=$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*))user) \
61 TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
62 PYTHONDONTWRITEBYTECODE=1 \
63 $(gb_TEST_ENV_VARS) \
64 $(ICECREAM_RUN) $(gb_PythonTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_CppunitTest_RR) \
65 $(gb_PythonTest_COMMAND) \
66 $(if $(PYTHON_TEST_NAME),$(PYTHON_TEST_NAME),$(MODULES)) \
67 $(if $(gb_PythonTest_POSTGDBTRACE), \
68 ; RET=$$? && $(gb_PythonTest_POSTGDBTRACE) && (exit $$RET)) \
69 ; } \
70 $(if $(gb_CppunitTest__interactive),, \
71 > $@.log 2>&1 \
72 || ($(if $(value gb_CppunitTest_postprocess), \
73 RET=$$?; \
74 $(call gb_CppunitTest_postprocess,$(gb_PythonTest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
75 cat $@.log; $(gb_PythonTest_UNITTESTFAILED) Python $*)))
76 $(call gb_Trace_EndRange,$*,PYT)
77 endif
79 # always use udkapi and URE services
80 define gb_PythonTest_PythonTest
81 $(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))
82 $(call gb_PythonTest_get_target,$(1)) : MODULES :=
84 $(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
85 $(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
87 endef
89 define gb_PythonTest_set_defs
90 $(call gb_PythonTest_get_target,$(1)) : DEFS := $(2)
92 endef
94 # put the directory on the PYTHONPATH because the "unittest" loader
95 # mysteriously fails to load modules given as absolute path unless the $PWD is
96 # a prefix of the absolute path, which it is not when we go into a certain
97 # dir to get a core dump there
99 # gb_PythonTest_add_modules directory module(s)
100 define gb_PythonTest_add_modules
101 $(call gb_PythonTest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(2)
102 $(call gb_PythonTest_get_target,$(1)) : MODULES += $(3)
104 endef
106 define gb_PythonTest_use_customtarget
107 $(call gb_PythonTest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
109 endef
112 else # DISABLE_PYTHON
114 .PHONY : $(call gb_PythonTest_get_target,$(1))
115 $(call gb_PythonTest_get_target,%) :
116 ifeq ($(gb_SUPPRESS_TESTS),)
117 $(call gb_Output_announce,$* (skipped - no PythonTest),$(true),PYT,2)
118 endif
119 @true
121 define gb_PythonTest_PythonTest
122 $(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
123 $(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
125 endef
127 gb_PythonTest_set_defs :=
128 gb_PythonTest_add_modules :=
129 gb_PythonTest_use_customtarget :=
131 endif # DISABLE_PYTHON
132 # vim: set noet sw=4: