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/.
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
)
19 gb_PythonTest_EXECUTABLE
:= $(PYTHON_FOR_BUILD
)
20 gb_PythonTest_EXECUTABLE_GDB
:= $(PYTHON_FOR_BUILD
)
24 gb_PythonTest_COMMAND
:= $(gb_PythonTest_EXECUTABLE
) -m 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
,%) :|
$(gb_PythonTest_DEPS
)
35 ifneq ($(gb_SUPPRESS_TESTS
),)
38 $(call gb_Output_announce
,$*,$(true
),PYT
,2)
39 $(call gb_Helper_abbreviate_dirs
,\
40 rm -rf
$(dir $(call gb_PythonTest_get_target
,$*)) && \
41 mkdir
-p
$(dir $(call gb_PythonTest_get_target
,$*)) && \
42 $(if
$(gb_CppunitTest__interactive
),, \
43 $(if
$(value gb_CppunitTest_postprocess
), \
44 rm -fr
$@.core
&& mkdir
$@.core
&& cd
$@.core
&&)) \
45 ($(gb_PythonTest_PRECOMMAND
) \
46 $(if
$(G_SLICE
),G_SLICE
=$(G_SLICE
)) \
47 $(if
$(GLIBCXX_FORCE_NEW
),GLIBCXX_FORCE_NEW
=$(GLIBCXX_FORCE_NEW
)) \
49 TEST_LIB
=$(call gb_Library_get_target
,test) \
50 URE_BOOTSTRAP
=vnd.sun.star.pathname
:$(call gb_Helper_get_rcfile
,$(INSTROOT
)/$(LIBO_ETC_FOLDER
)/fundamental
) \
51 PYTHONPATH
="$(PYPATH)" \
52 UserInstallation
=$(call gb_Helper_make_url
,$(dir $(call gb_PythonTest_get_target
,$*))user
) \
53 TestUserDir
="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
54 PYTHONDONTWRITEBYTECODE
=1 \
55 $(if
$(filter-out MACOSX WNT
,$(OS_FOR_BUILD
)),$(if
$(ENABLE_HEADLESS
),, \
56 SAL_USE_VCLPLUGIN
=svp \
58 $(gb_CppunitTest_GDBTRACE
) $(gb_CppunitTest_VALGRINDTOOL
) \
59 $(gb_PythonTest_COMMAND
) \
60 $(if
$(PYTHON_TEST_NAME
),$(PYTHON_TEST_NAME
),$(MODULES
)) \
61 $(if
$(gb_CppunitTest__interactive
),, \
63 ||
($(if
$(value gb_CppunitTest_postprocess
), \
65 $(call gb_CppunitTest_postprocess
,$(gb_PythonTest_EXECUTABLE_GDB
),$@.core
,$$RET) >> $@.log
2>&1;) \
66 cat
$@.log
; $(gb_PythonTest_UNITTESTFAILED
) Python
$*))))
69 # always use udkapi and URE services
70 define gb_PythonTest_PythonTest
71 $(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
))
72 $(call gb_PythonTest_get_target
,$(1)) : MODULES
:=
74 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
75 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
79 define gb_PythonTest_set_defs
80 $(call gb_PythonTest_get_target
,$(1)) : DEFS
:= $(2)
84 # put the directory on the PYTHONPATH because the "unittest" loader
85 # mysteriously fails to load modules given as absolute path unless the $PWD is
86 # a prefix of the absolute path, which it is not when we go into a certain
87 # dir to get a core dump there
89 # gb_PythonTest_add_modules directory module(s)
90 define gb_PythonTest_add_modules
91 $(call gb_PythonTest_get_target
,$(1)) : PYPATH
:= $$(PYPATH
)$$(gb_CLASSPATHSEP
)$(2)
92 $(call gb_PythonTest_get_target
,$(1)) : MODULES
+= $(3)
96 define gb_PythonTest_use_customtarget
97 $(call gb_PythonTest_get_target
,$(1)) : $(call gb_CustomTarget_get_workdir
,$(2))
102 else # DISABLE_PYTHON
104 .PHONY
: $(call gb_PythonTest_get_target
,$(1))
105 $(call gb_PythonTest_get_target
,%) :
106 ifeq ($(gb_SUPPRESS_TESTS
),)
107 $(call gb_Output_announce
,$* (skipped
- no PythonTest
),$(true
),PYT
,2)
111 define gb_PythonTest_PythonTest
112 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
113 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
117 gb_PythonTest_set_defs
:=
118 gb_PythonTest_add_modules
:=
119 gb_PythonTest_use_customtarget
:=
121 endif # DISABLE_PYTHON
122 # vim: set noet sw=4: