Avoid potential negative array index access to cached text.
[LibreOffice.git] / solenv / gbuild / UITest.mk
blob334080b70a70ba51836cdbd7d3db6bbe344670dd
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 = $(ICECREAM_RUN) $(gb_CppunitTest_coredumpctl_run) $(gb_CppunitTest_RR) $(gb_UITest_EXECUTABLE) $(SRCDIR)/uitest/test_main.py
42 gb_TEST_ENV_VARS += LIBO_LANG=C
44 .PHONY : $(call gb_UITest_get_clean_target,%)
45 $(call gb_UITest_get_clean_target,%) :
46 $(call gb_Helper_abbreviate_dirs,\
47 rm -f $@ $@.log)
49 ifneq ($(DISABLE_PYTHON),TRUE)
51 # qadevOOo/qa/registrymodifications.xcu is copied to user profile directory to ensure en_US locale;
52 # this might be overwritten later when gb_UITest_use_config is set
53 .PHONY : $(call gb_UITest_get_target,%)
54 $(call gb_UITest_get_target,%) :| $(gb_UITest_DEPS)
55 ifneq ($(gb_SUPPRESS_TESTS),)
56 @true
57 else
58 $(call gb_Output_announce,$*,$(true),UIT,2)
59 $(call gb_Trace_StartRange,$*,UIT)
60 $(call gb_Helper_abbreviate_dirs,\
61 rm -rf $(dir $(call gb_UITest_get_target,$*)) && \
62 mkdir -p $(dir $(call gb_UITest_get_target,$*))/user/user && \
63 cp -T $(if $(gb_UITest_use_config),$(gb_UITest_use_config),$(SRCDIR)/qadevOOo/qa/registrymodifications.xcu) $(dir $(call gb_UITest_get_target,$*))/user/user/registrymodifications.xcu && \
64 $(if $(gb_UITest__interactive),, \
65 rm -fr $@.core && mkdir -p $(dir $(call gb_UITest_get_target,$*))user/ && mkdir $@.core && cd $@.core && ) \
66 $(call gb_CppunitTest_coredumpctl_setup,$@) \
67 ($(gb_UITest_PRECOMMAND) \
68 $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
69 $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
70 $(DEFS) \
71 $(if $(filter WNT,$(OS)),SAL_LOG_FILE="$(dir $(call gb_UITest_get_target,$*))/soffice.out.log") \
72 TEST_LIB=$(call gb_Library_get_target,test) \
73 URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
74 PYTHONPATH="$(PYPATH)" \
75 TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*)))" \
76 PYTHONDONTWRITEBYTECODE=0 \
77 $(if $(ENABLE_WERROR),PYTHONWARNINGS=error) \
78 $(if $(filter WNT,$(OS)),TZ=) \
79 $(gb_TEST_ENV_VARS) \
80 $(gb_UITest_COMMAND) \
81 --soffice="$(gb_UITest_SOFFICEARG)" \
82 $(if $(ONEPROCESS),--oneprocess) \
83 --userdir=$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*))user) \
84 --dir=$(strip $(MODULES)) \
85 $(gb_UITest_GDBTRACE) \
86 $(if $(gb_UITest__interactive),, \
87 > $@.log 2>&1 \
88 || ($(if $(value gb_CppunitTest_postprocess), \
89 RET=$$?; \
90 $(call gb_CppunitTest_postprocess,$(gb_UITest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
91 $(if $(filter WNT,$(OS)), \
92 printf '%s: <<<\n' $(dir $(call gb_UITest_get_target,$*))/soffice.out.log; \
93 cat $(dir $(call gb_UITest_get_target,$*))/soffice.out.log; \
94 printf ' >>>\n\n';) \
95 cat $@.log; $(gb_UITest_UNITTESTFAILED) UI $*))))
96 $(call gb_Trace_EndRange,$*,UIT)
97 endif
99 # always use udkapi and URE services
100 define gb_UITest_UITest
101 $(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))
102 $(call gb_UITest_get_target,$(1)) : MODULES :=
104 $(eval $(call gb_TestHelpers_use_more_fonts,$(call gb_UITest_get_target,$(1))))
105 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
106 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
107 $(call gb_UITest_get_target,$(1)) : ONEPROCESS := $(true)
109 endef
111 define gb_UITest_set_defs
112 $(call gb_UITest_get_target,$(1)) : DEFS := $(2)
114 endef
116 # put the directory on the PYTHONPATH because the "unittest" loader
117 # mysteriously fails to load modules given as absolute path unless the $PWD is
118 # a prefix of the absolute path, which it is not when we go into a certain
119 # dir to get a core dump there
121 # gb_UITest_add_modules directory module(s)
122 define gb_UITest_add_modules
123 $(call gb_UITest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(strip $(2))/$(strip $(3))
124 $(call gb_UITest_get_target,$(1)) : MODULES += $(strip $(2))/$(strip $(3))
126 endef
128 define gb_UITest_use_customtarget
129 $(call gb_UITest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
131 endef
133 define gb_UITest_use_configuration
134 $(call gb_UITest_get_target,$(1)) : gb_UITest_use_config := $(2)
135 endef
137 define gb_UITest_avoid_oneprocess
138 $(call gb_UITest_get_target,$(1)) : ONEPROCESS := $(false)
139 endef
142 else # DISABLE_PYTHON
144 .PHONY : $(call gb_UITest_get_target,$(1))
145 $(call gb_UITest_get_target,%) :
146 ifeq ($(gb_SUPPRESS_TESTS),)
147 $(call gb_Output_announce,$* (skipped - no UITest),$(true),PYT,2)
148 endif
149 @true
151 define gb_UITest_UITest
152 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
153 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
155 endef
157 gb_UITest_set_defs :=
158 gb_UITest_add_modules :=
159 gb_UITest_use_customtarget :=
161 endif # DISABLE_PYTHON
162 # vim: set noet sw=4: