summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2013-03-30 22:10:48 +0100
committerDavid Ostrovsky <David.Ostrovsky@gmx.de>2013-04-09 05:52:23 +0000
commit0e68bac85293e2d60fa6db3e46de8b74ab5d502b (patch)
tree17b4edeb6bfbce3724de003a87718d6b8f895642 /solenv
parentd64b5cc1c3d232ba42479fe0a3c186ecabd25144 (diff)
set up python unit test infrastructure
Extract boostraping code from convwatch.py to unotest.py. Use python builtin unittest module as unit test framework. Specify the unit test modules in make file. Another option would be to use discover mode of unittest module. Add __pycache__ to global .gitignore to keep the source directory clean. Another option would be to deliver the unit tests to workdir prior to test execution. Currently only system python3 is supported. Change-Id: I2692817673f786e950e1176a17c7675f989755b6 Reviewed-on: https://gerrit.libreoffice.org/3214 Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de> Tested-by: David Ostrovsky <David.Ostrovsky@gmx.de>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/gbuild/PythonTest.mk83
-rw-r--r--solenv/gbuild/TargetLocations.mk2
-rw-r--r--solenv/gbuild/gbuild.mk1
3 files changed, 86 insertions, 0 deletions
diff --git a/solenv/gbuild/PythonTest.mk b/solenv/gbuild/PythonTest.mk
new file mode 100644
index 000000000000..d97b2a83f5e0
--- /dev/null
+++ b/solenv/gbuild/PythonTest.mk
@@ -0,0 +1,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:
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index 7f50cf6a7574..3ea8951178ce 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -148,6 +148,7 @@ gb_JavaClassSet_get_target = $(WORKDIR)/JavaClassSet/$(1)/done
gb_JunitTest_get_classsetname = JunitTest/$(1)
gb_JunitTest_get_target = $(WORKDIR)/JunitTest/$(1)/done
gb_JunitTest_get_userdir = $(WORKDIR)/JunitTest/$(1)/user
+gb_PythonTest_get_target = $(WORKDIR)/PythonTest/$(1)/done
gb_LinkTarget_get_external_headers_target = $(WORKDIR)/ExternalHeaders/$(1)
gb_LinkTarget_get_headers_target = $(WORKDIR)/Headers/$(1)
gb_LinkTarget_get_target = $(WORKDIR)/LinkTarget/$(1)
@@ -290,6 +291,7 @@ $(eval $(call gb_Helper_make_clean_targets,\
Pagein \
PrecompiledHeader \
Pyuno \
+ PythonTest \
Rdb \
ResTarget \
ScpMergeTarget \
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index cb374dad3851..3d2796fe965d 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -313,6 +313,7 @@ include $(foreach class, \
Pagein \
PrecompiledHeaders \
Pyuno \
+ PythonTest \
Rdb \
CppunitTest \
Jar \