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
),NO
)
13 gb_PythonTest_EXECUTABLE
:= $(gb_Python_INSTALLED_EXECUTABLE
)
14 gb_PythonTest_EXECUTABLE_GDB
:= $(gb_Python_INSTALLED_EXECUTABLE_GDB
)
16 gb_PythonTest_EXECUTABLE
:= $(PYTHON_FOR_BUILD
)
17 gb_PythonTest_EXECUTABLE_GDB
:= $(PYTHON_FOR_BUILD
)
20 gb_PythonTest_COMMAND
:= $(gb_PythonTest_EXECUTABLE
) -m unittest
22 .PHONY
: $(call gb_PythonTest_get_clean_target
,%)
23 $(call gb_PythonTest_get_clean_target
,%) :
24 $(call gb_Helper_abbreviate_dirs
,\
27 ifneq ($(DISABLE_PYTHON
),TRUE
)
29 # pass a hard-coded 139 to the gdb postprocess script to match soffice.bin
30 # signal exit values (assumption: non-0 exit value here means it crashed)
31 .PHONY
: $(call gb_PythonTest_get_target
,%)
32 $(call gb_PythonTest_get_target
,%) :
33 $(call gb_Output_announce
,$*,$(true
),PYT
,2)
34 $(call gb_Helper_abbreviate_dirs
,\
35 rm -rf
$(dir $(call gb_PythonTest_get_target
,$*)) && \
36 mkdir
-p
$(dir $(call gb_PythonTest_get_target
,$*)) && \
37 $(if
$(gb_CppunitTest__interactive
),, \
38 $(if
$(value gb_CppunitTest_postprocess
), \
39 rm -fr
$@.core
&& mkdir
$@.core
&& cd
$@.core
&&)) \
40 ($(gb_PythonTest_PRECOMMAND
) \
41 $(if
$(G_SLICE
),G_SLICE
=$(G_SLICE
)) \
42 $(if
$(GLIBCXX_FORCE_NEW
),GLIBCXX_FORCE_NEW
=$(GLIBCXX_FORCE_NEW
)) \
43 URE_BOOTSTRAP
=vnd.sun.star.pathname
:$(gb_DEVINSTALLROOT
)/program
/fundamentalrc \
44 PYTHONPATH
=$(PYPATH
) \
45 UserInstallation
="$(call gb_Helper_make_url,$(OUTDIR)/unittest)" \
46 TestUserDir
="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
47 $(gb_CppunitTest_GDBTRACE
) $(gb_CppunitTest_VALGRINDTOOL
) $(gb_PythonTest_COMMAND
) \
49 $(if
$(gb_CppunitTest__interactive
),, \
51 ||
(cat
$@.log
&& $(call gb_UNIT_FAILED_MSG
,Python
,$*) \
52 $(if
$(value gb_CppunitTest_postprocess
), \
53 && $(call gb_CppunitTest_postprocess
,$(gb_PythonTest_EXECUTABLE_GDB
),$@.core
,139)) \
56 # always use udkapi and URE services
57 define gb_PythonTest_PythonTest
58 $(call gb_PythonTest_get_target
,$(1)) : PYPATH
:= $(SRCDIR
)/unotest
/source
/python
:$(gb_DEVINSTALLROOT
)/program
59 $(call gb_PythonTest_get_target
,$(1)) : MODULES
:=
61 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
62 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
66 # put the directory on the PYTHONPATH because the "unittest" loader
67 # mysteriously fails to load modules given as absolute path unless the $PWD is
68 # a prefix of the absolute path, which it is not when we go into a certain
69 # dir to get a core dump there
71 # gb_PythonTest_add_modules directory module(s)
72 define gb_PythonTest_add_modules
73 $(call gb_PythonTest_get_target
,$(1)) : PYPATH
:= $$(PYPATH
):$(2)
74 $(call gb_PythonTest_get_target
,$(1)) : MODULES
+= $(3)
78 define gb_PythonTest_use_customtarget
79 $(call gb_PythonTest_get_target
,$(1)) : $(call gb_CustomTarget_get_workdir
,$(2))
86 .PHONY
: $(call gb_PythonTest_get_target
,$(1))
87 $(call gb_PythonTest_get_target
,%) :
88 $(call gb_Output_announce
,$* (skipped
- no PythonTest
),$(true
),PYT
,2)
91 define gb_PythonTest_PythonTest
92 $(eval
$(call gb_Module_register_target
,$(call gb_PythonTest_get_target
,$(1)),$(call gb_PythonTest_get_clean_target
,$(1))))
93 $(call gb_Helper_make_userfriendly_targets
,$(1),PythonTest
)
97 gb_PythonTest_add_modules
:=
98 gb_PythonTest_use_customtarget
:=
100 endif # DISABLE_PYTHON
101 # vim: set noet sw=4: