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
,$*)) && \
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 \
58 $(if
$(filter-out MACOSX WNT
,$(OS_FOR_BUILD
)),$(if
$(DISABLE_GUI
),, \
59 SAL_USE_VCLPLUGIN
=svp \
61 $(gb_CppunitTest_GDBTRACE
) $(gb_CppunitTest_VALGRINDTOOL
) $(gb_CppunitTest_RR
) \
62 $(gb_PythonTest_COMMAND
) \
63 $(if
$(PYTHON_TEST_NAME
),$(PYTHON_TEST_NAME
),$(MODULES
)) \
64 $(if
$(gb_CppunitTest__interactive
),, \
66 ||
($(if
$(value gb_CppunitTest_postprocess
), \
68 $(call gb_CppunitTest_postprocess
,$(gb_PythonTest_EXECUTABLE_GDB
),$@.core
,$$RET) >> $@.log
2>&1;) \
69 cat
$@.log
; $(gb_PythonTest_UNITTESTFAILED
) Python
$*))))
72 # always use udkapi and URE services
73 define gb_PythonTest_PythonTest
74 $(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
))
75 $(call gb_PythonTest_get_target
,$(1)) : MODULES
:=
77 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
78 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
82 define gb_PythonTest_set_defs
83 $(call gb_PythonTest_get_target
,$(1)) : DEFS
:= $(2)
87 # put the directory on the PYTHONPATH because the "unittest" loader
88 # mysteriously fails to load modules given as absolute path unless the $PWD is
89 # a prefix of the absolute path, which it is not when we go into a certain
90 # dir to get a core dump there
92 # gb_PythonTest_add_modules directory module(s)
93 define gb_PythonTest_add_modules
94 $(call gb_PythonTest_get_target
,$(1)) : PYPATH
:= $$(PYPATH
)$$(gb_CLASSPATHSEP
)$(2)
95 $(call gb_PythonTest_get_target
,$(1)) : MODULES
+= $(3)
99 define gb_PythonTest_use_customtarget
100 $(call gb_PythonTest_get_target
,$(1)) : $(call gb_CustomTarget_get_workdir
,$(2))
105 else # DISABLE_PYTHON
107 .PHONY
: $(call gb_PythonTest_get_target
,$(1))
108 $(call gb_PythonTest_get_target
,%) :
109 ifeq ($(gb_SUPPRESS_TESTS
),)
110 $(call gb_Output_announce
,$* (skipped
- no PythonTest
),$(true
),PYT
,2)
114 define gb_PythonTest_PythonTest
115 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
116 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
120 gb_PythonTest_set_defs
:=
121 gb_PythonTest_add_modules
:=
122 gb_PythonTest_use_customtarget
:=
124 endif # DISABLE_PYTHON
125 # vim: set noet sw=4: