Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / solenv / gbuild / UITest.mk
blob03d30448ef7b0fadc14f9441ab887ec3d205923c
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/.
10 # UITest class
12 gb_UITest_UNITTESTFAILED ?= $(GBUILDDIR)/uitest-failed-default.sh
14 ifeq ($(SYSTEM_PYTHON),)
15 gb_UITest_EXECUTABLE := $(gb_Python_INSTALLED_EXECUTABLE)
16 gb_UITest_DEPS ?= $(call gb_Package_get_target,python3)
17 else
18 gb_UITest_EXECUTABLE := $(PYTHON_FOR_BUILD)
19 gb_UITest_DEPS :=
20 endif
22 # UITests are much more likely to generate core files for the soffice than for
23 # the python executable, but solenv/bin/gdb-core-bt.sh is often unable to
24 # determine the executable that generated a core file, so make it fall back to
25 # the soffice executable rather than to gb_UITest_EXECUTABLE:
26 gb_UITest_EXECUTABLE_GDB := $(call gb_Executable_get_target,soffice_bin)
28 ifneq ($(strip $(UITESTTRACE)),)
29 gb_UITest_GDBTRACE := --gdb
30 gb_UITest__interactive := $(true)
31 endif
33 ifneq ($(gb_UITest_DEBUGRUN),)
34 gb_UITest_SOFFICEARG:=connect:pipe,name=$(USER)
35 gb_UITest__interactive := $(true)
36 else
37 gb_UITest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
38 endif
40 gb_UITest_COMMAND := LIBO_LANG=en_US.UTF-8 $(gb_UITest_EXECUTABLE) $(SRCDIR)/uitest/test_main.py
42 .PHONY : $(call gb_UITest_get_clean_target,%)
43 $(call gb_UITest_get_clean_target,%) :
44 $(call gb_Helper_abbreviate_dirs,\
45 rm -f $@ $@.log)
47 ifneq ($(DISABLE_PYTHON),TRUE)
49 .PHONY : $(call gb_UITest_get_target,%)
50 $(call gb_UITest_get_target,%) :| $(gb_UITest_DEPS)
51 ifneq ($(gb_SUPPRESS_TESTS),)
52 @true
53 else
54 $(call gb_Output_announce,$*,$(true),UIT,2)
55 $(call gb_Helper_abbreviate_dirs,\
56 rm -rf $(dir $(call gb_UITest_get_target,$*)) && \
57 mkdir -p $(dir $(call gb_UITest_get_target,$*)) && \
58 $(if $(gb_UITest__interactive),, \
59 rm -fr $@.core && mkdir -p $(dir $(call gb_UITest_get_target,$*))user/ && mkdir $@.core && cd $@.core && ) \
60 $(if $(gb_UITest_use_config), \
61 cp $(gb_UITest_use_config) $(dir $(call gb_UITest_get_target,$*))user/. && ) \
62 ($(gb_UITest_PRECOMMAND) \
63 $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
64 $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
65 $(DEFS) \
66 $(if $(filter WNT,$(OS)),SAL_LOG_FILE="$(dir $(call gb_UITest_get_target,$*))/soffice.out.log") \
67 TEST_LIB=$(call gb_Library_get_target,test) \
68 URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
69 PYTHONPATH="$(PYPATH)" \
70 TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*)))" \
71 PYTHONDONTWRITEBYTECODE=0 \
72 $(if $(filter-out MACOSX WNT,$(OS_FOR_BUILD)),$(if $(ENABLE_HEADLESS),, \
73 SAL_USE_VCLPLUGIN=svp \
74 )) \
75 $(gb_UITest_COMMAND) \
76 --soffice="$(gb_UITest_SOFFICEARG)" \
77 --userdir=$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*))user) \
78 --dir=$(strip $(MODULES)) \
79 $(gb_UITest_GDBTRACE) \
80 $(if $(gb_UITest__interactive),, \
81 > $@.log 2>&1 \
82 || ($(if $(value gb_CppunitTest_postprocess), \
83 RET=$$?; \
84 $(call gb_CppunitTest_postprocess,$(gb_UITest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
85 $(if $(filter WNT,$(OS)), \
86 printf '%s: <<<\n' $(dir $(call gb_UITest_get_target,$*))/soffice.out.log; \
87 cat $(dir $(call gb_UITest_get_target,$*))/soffice.out.log; \
88 printf ' >>>\n\n';) \
89 cat $@.log; $(gb_UITest_UNITTESTFAILED) UI $*))))
90 endif
92 # always use udkapi and URE services
93 define gb_UITest_UITest
94 $(call gb_UITest_get_target,$(1)) : PYPATH := $(SRCDIR)/uitest$$(gb_CLASSPATHSEP)$(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))
95 $(call gb_UITest_get_target,$(1)) : MODULES :=
97 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
98 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
100 endef
102 define gb_UITest_set_defs
103 $(call gb_UITest_get_target,$(1)) : DEFS := $(2)
105 endef
107 # put the directory on the PYTHONPATH because the "unittest" loader
108 # mysteriously fails to load modules given as absolute path unless the $PWD is
109 # a prefix of the absolute path, which it is not when we go into a certain
110 # dir to get a core dump there
112 # gb_UITest_add_modules directory module(s)
113 define gb_UITest_add_modules
114 $(call gb_UITest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(strip $(2))/$(strip $(3))
115 $(call gb_UITest_get_target,$(1)) : MODULES += $(strip $(2))/$(strip $(3))
117 endef
119 define gb_UITest_use_customtarget
120 $(call gb_UITest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
122 endef
124 define gb_UITest_use_configuration
125 $(call gb_UITest_get_target,$(1)) : gb_UITest_use_config := $(2)
126 endef
129 else # DISABLE_PYTHON
131 .PHONY : $(call gb_UITest_get_target,$(1))
132 $(call gb_UITest_get_target,%) :
133 ifeq ($(gb_SUPPRESS_TESTS),)
134 $(call gb_Output_announce,$* (skipped - no UITest),$(true),PYT,2)
135 endif
136 @true
138 define gb_UITest_UITest
139 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
140 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
142 endef
144 gb_UITest_set_defs :=
145 gb_UITest_add_modules :=
146 gb_UITest_use_customtarget :=
148 endif # DISABLE_PYTHON
149 # vim: set noet sw=4: