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 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
),)
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
)) \
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 \
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
),, \
64 ||
($(if
$(value gb_CppunitTest_postprocess
), \
66 $(call gb_CppunitTest_postprocess
,$(gb_PythonTest_EXECUTABLE_GDB
),$@.core
,$$RET) >> $@.log
2>&1;) \
67 cat
$@.log
; $(gb_PythonTest_UNITTESTFAILED
) Python
$*))))
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
)
80 define gb_PythonTest_set_defs
81 $(call gb_PythonTest_get_target
,$(1)) : DEFS
:= $(2)
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)
97 define gb_PythonTest_use_customtarget
98 $(call gb_PythonTest_get_target
,$(1)) : $(call gb_CustomTarget_get_workdir
,$(2))
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)
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
)
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: