summaryrefslogtreecommitdiff
path: root/solenv/gbuild/PythonTest.mk
blob: d97b2a83f5e051dc8be0890e36263359d8376f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

# PythonTest class

# TODO: FixMe problem with internal python:
# Fatal Python error: Py_Initialize: Unable to get the locale encoding
#gb_Python_EXE := $(call gb_Executable_get_command,python)
gb_Python_EXE := python3

gb_PythonTest_COMMAND := $(gb_Python_EXE) -m unittest

.PHONY : $(call gb_PythonTest_get_clean_target,%)
$(call gb_PythonTest_get_clean_target,%) :
	$(call gb_Helper_abbreviate_dirs,\
		rm -f $@ $@.log)

ifneq ($(DISABLE_PYTHON),TRUE)

.PHONY : $(call gb_PythonTest_get_target,%)
$(call gb_PythonTest_get_target,%) :
	$(call gb_Output_announce,$*,$(true),PYT,2)
	$(call gb_Helper_abbreviate_dirs,\
        mkdir -p $(dir $(call gb_PythonTest_get_target,$*)) && \
        (PYTHONPATH=$(SRCDIR)/unotest/source/python:$(DEVINSTALLDIR)/opt/program \
         SOFFICE_BIN=$(DEVINSTALLDIR)/opt/program/soffice \
         URE_BOOTSTRAP=file://$(DEVINSTALLDIR)/opt/program/fundamentalrc \
		    $(gb_PythonTest_COMMAND) \
            $(CLASSES) > $@.log 2>&1 || \
		(cat $@.log \
		&& false)))
	$(CLEAN_CMD)

define gb_PythonTest_PythonTest
$(call gb_PythonTest_get_target,$(1)) : T_CP :=
$(call gb_PythonTest_get_target,$(1)) : CLASSES :=

$(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
$(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)

endef

define gb_PythonTest_add_classes
$(call gb_PythonTest_get_target,$(1)) : CLASSES += $(2)

endef

define gb_PythonTest_add_class
$(call gb_PythonTest_add_classes,$(1),$(2))

endef

define gb_PythonTest_use_customtarget
$(call gb_PythonTest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))

endef


else # DISABLE_PYTHON

.PHONY : $(call gb_PythonTest_get_target,$(1))
$(call gb_PythonTest_get_target,%) :
	$(call gb_Output_announce,$* (skipped - no PythonTest),$(true),PYT,2)
	@true

define gb_PythonTest_PythonTest
$(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call gb_PythonTest_get_clean_target,$(1))))
$(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)

endef

gb_PythonTest_add_classes :=
gb_PythonTest_add_class :=
gb_JunitTest_use_customtarget :=

endif # DISABLE_PYTHON
# vim: set noet sw=4: