gbuild: ExternalProject: improve NMAKE handling
[LibreOffice.git] / solenv / gbuild / UITest.mk
blob1edb3f76908181bdb5b2b14ec4462cd6dd5ba436
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)/platform/unittest-failed-default.sh
14 ifeq ($(SYSTEM_PYTHON),)
15 gb_UITest_EXECUTABLE := $(gb_Python_INSTALLED_EXECUTABLE)
16 gb_UITest_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE_GDB)
17 gb_UITest_DEPS ?= $(call gb_Package_get_target,python3)
18 else
19 gb_UITest_EXECUTABLE := $(PYTHON_FOR_BUILD)
20 gb_UITest_EXECUTABLE_GDB := $(PYTHON_FOR_BUILD)
21 gb_UITest_DEPS :=
22 endif
24 ifneq ($(strip $(UITESTTRACE)),)
25 gb_UITest_GDBTRACE := --gdb
26 gb_UITest__interactive := $(true)
27 endif
29 gb_UITest_COMMAND := $(gb_UITest_EXECUTABLE) $(SRCDIR)/uitest/test_main.py
31 .PHONY : $(call gb_UITest_get_clean_target,%)
32 $(call gb_UITest_get_clean_target,%) :
33 $(call gb_Helper_abbreviate_dirs,\
34 rm -f $@ $@.log)
36 ifneq ($(DISABLE_PYTHON),TRUE)
38 .PHONY : $(call gb_UITest_get_target,%)
39 $(call gb_UITest_get_target,%) :| $(gb_UITest_DEPS)
40 $(call gb_Output_announce,$*,$(true),UIT,2)
41 $(call gb_Helper_abbreviate_dirs,\
42 rm -rf $(dir $(call gb_UITest_get_target,$*)) && \
43 mkdir -p $(dir $(call gb_UITest_get_target,$*)) && \
44 $(if $(gb_UITest__interactive),, \
45 rm -fr $@.core && mkdir -p $(dir $(call gb_UITest_get_target,$*))user/ && mkdir $@.core && cd $@.core && ) \
46 $(if $(gb_UITest_use_config), \
47 cp $(gb_UITest_use_config) $(dir $(call gb_UITest_get_target,$*))user/. && ) \
48 ($(gb_UITest_PRECOMMAND) \
49 $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
50 $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
51 $(DEFS) \
52 SAL_LOG_FILE="$(dir $(call gb_UITest_get_target,$*))/soffice.out.log" \
53 TEST_LIB=$(call gb_Library_get_target,test) \
54 URE_BOOTSTRAP=vnd.sun.star.pathname:$(call gb_Helper_get_rcfile,$(INSTROOT)/$(LIBO_ETC_FOLDER)/fundamental) \
55 PYTHONPATH="$(PYPATH)" \
56 TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*)))" \
57 PYTHONDONTWRITEBYTECODE=0 \
58 $(if $(filter-out MACOSX WNT,$(OS_FOR_BUILD)),$(if $(ENABLE_HEADLESS),, \
59 SAL_USE_VCLPLUGIN=svp \
60 )) \
61 $(gb_UITest_COMMAND) \
62 --soffice=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice \
63 --userdir=$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*))user) \
64 --dir=$(strip $(MODULES)) \
65 $(gb_UITest_GDBTRACE) \
66 $(if $(gb_UITest__interactive),, \
67 > $@.log 2>&1 \
68 || ($(if $(value gb_CppunitTest_postprocess), \
69 RET=$$?; \
70 $(call gb_CppunitTest_postprocess,$(gb_UITest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
71 cat $@.log; $(gb_UITest_UNITTESTFAILED) UI $*))))
73 # always use udkapi and URE services
74 define gb_UITest_UITest
75 $(call gb_UITest_get_target,$(1)) : PYPATH := $(SRCDIR)/uitest$$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_PYUNO_FOLDER)$(if $(filter-out $(LIBO_LIB_PYUNO_FOLDER),$(LIBO_LIB_FOLDER)),$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_FOLDER))
76 $(call gb_UITest_get_target,$(1)) : MODULES :=
78 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
79 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
81 endef
83 define gb_UITest_set_defs
84 $(call gb_UITest_get_target,$(1)) : DEFS := $(2)
86 endef
88 # put the directory on the PYTHONPATH because the "unittest" loader
89 # mysteriously fails to load modules given as absolute path unless the $PWD is
90 # a prefix of the absolute path, which it is not when we go into a certain
91 # dir to get a core dump there
93 # gb_UITest_add_modules directory module(s)
94 define gb_UITest_add_modules
95 $(call gb_UITest_get_target,$(1)) : PYPATH := $$(PYPATH)$$(gb_CLASSPATHSEP)$(strip $(2))/$(strip $(3))
96 $(call gb_UITest_get_target,$(1)) : MODULES += $(strip $(2))/$(strip $(3))
98 endef
100 define gb_UITest_use_customtarget
101 $(call gb_UITest_get_target,$(1)) : $(call gb_CustomTarget_get_workdir,$(2))
103 endef
105 define gb_UITest_use_configuration
106 $(call gb_UITest_get_target,$(1)) : gb_UITest_use_config := $(2)
107 endef
110 else # DISABLE_PYTHON
112 .PHONY : $(call gb_UITest_get_target,$(1))
113 $(call gb_UITest_get_target,%) :
114 $(call gb_Output_announce,$* (skipped - no UITest),$(true),PYT,2)
115 @true
117 define gb_UITest_UITest
118 $(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
119 $(call gb_Helper_make_userfriendly_targets,$(1),UITest)
121 endef
123 gb_UITest_set_defs :=
124 gb_UITest_add_modules :=
125 gb_UITest_use_customtarget :=
127 endif # DISABLE_PYTHON
128 # vim: set noet sw=4: