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 ifeq ($(SYSTEM_PYTHON
),)
13 gb_PythonTest_EXECUTABLE
:= $(gb_Python_INSTALLED_EXECUTABLE
)
14 gb_PythonTest_EXECUTABLE_GDB
:= $(gb_Python_INSTALLED_EXECUTABLE_GDB
)
16 gb_PythonTest_DEPS
:= $(call gb_GeneratedPackage_get_target
,python3
)
18 gb_PythonTest_DEPS
:= $(call gb_Package_get_target
,python3
)
20 gb_PythonTest_DEPS
+= $(if
$(filter-out WNT
,$(OS
)),$(call gb_Package_get_target
,python_shell
))
22 gb_PythonTest_EXECUTABLE
:= $(PYTHON_FOR_BUILD
)
23 gb_PythonTest_EXECUTABLE_GDB
:= $(PYTHON_FOR_BUILD
)
27 gb_PythonTest_COMMAND
:= $(gb_PythonTest_EXECUTABLE
) -m unittest
29 .PHONY
: $(call gb_PythonTest_get_clean_target
,%)
30 $(call gb_PythonTest_get_clean_target
,%) :
31 $(call gb_Helper_abbreviate_dirs
,\
34 ifneq ($(DISABLE_PYTHON
),TRUE
)
36 .PHONY
: $(call gb_PythonTest_get_target
,%)
37 $(call gb_PythonTest_get_target
,%) :|
$(gb_PythonTest_DEPS
)
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
) \
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
; $(SRCDIR
)/solenv
/bin
/unittest-failed.sh Python
$*))))
68 # always use udkapi and URE services
69 define gb_PythonTest_PythonTest
70 $(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
))
71 $(call gb_PythonTest_get_target
,$(1)) : MODULES
:=
73 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
74 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
78 define gb_PythonTest_set_defs
79 $(call gb_PythonTest_get_target
,$(1)) : DEFS
:= $(2)
83 # put the directory on the PYTHONPATH because the "unittest" loader
84 # mysteriously fails to load modules given as absolute path unless the $PWD is
85 # a prefix of the absolute path, which it is not when we go into a certain
86 # dir to get a core dump there
88 # gb_PythonTest_add_modules directory module(s)
89 define gb_PythonTest_add_modules
90 $(call gb_PythonTest_get_target
,$(1)) : PYPATH
:= $$(PYPATH
)$$(gb_CLASSPATHSEP
)$(2)
91 $(call gb_PythonTest_get_target
,$(1)) : MODULES
+= $(3)
95 define gb_PythonTest_use_customtarget
96 $(call gb_PythonTest_get_target
,$(1)) : $(call gb_CustomTarget_get_workdir
,$(2))
101 else # DISABLE_PYTHON
103 .PHONY
: $(call gb_PythonTest_get_target
,$(1))
104 $(call gb_PythonTest_get_target
,%) :
105 $(call gb_Output_announce
,$* (skipped
- no PythonTest
),$(true
),PYT
,2)
108 define gb_PythonTest_PythonTest
109 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
110 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
114 gb_PythonTest_set_defs
:=
115 gb_PythonTest_add_modules
:=
116 gb_PythonTest_use_customtarget
:=
118 endif # DISABLE_PYTHON
119 # vim: set noet sw=4: