changeset 1534:e5394f3f30d3

Added code-coverage for rust launchers * .Makefile.am: declared target counting code coverage on rust launchers based on kcov * acinclude.m4: declared checkfor kcov directory * configure.ac: added optional check for kcov
author Jiri Vanek <jvanek@redhat.com>
date Mon, 14 Jan 2019 09:48:26 +0100
parents ab5d4f74c562
children cc006da2a3f6
files ChangeLog Makefile.am acinclude.m4 configure.ac
diffstat 4 files changed, 77 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 09 16:16:54 2019 +0100
+++ b/ChangeLog	Mon Jan 14 09:48:26 2019 +0100
@@ -1,3 +1,10 @@
+2019-01-14  Jiri Vanek <jvanek@redhat.com>
+
+	Added code-coverage for rust launchers
+	* .Makefile.am: declared target counting code coverage on rust launchers based on kcov
+	* acinclude.m4: declared checkfor kcov directory
+	* configure.ac: added optional check for kcov
+
 2019-01-09  Jiri Vanek <jvanek@redhat.com>
 
 	Made rust launchers to resovle jars, compose classpath and this run itw
--- a/Makefile.am	Wed Jan 09 16:16:54 2019 +0100
+++ b/Makefile.am	Mon Jan 14 09:48:26 2019 +0100
@@ -923,17 +923,17 @@
 	  unset PROGRAM_NAME ; \
 	  if [ $$filename = $(javaws) ] ; then \
 	    export MAIN_CLASS=net.sourceforge.jnlp.runtime.Boot ; \
-	    export BIN_LOCATION=$(bindir)/$(javaws).sh ; \
+	    export BIN_LOCATION=$(bindir)/$(javaws) ; \
 	    export PROGRAM_NAME=$(javaws) ; \
 	  fi ; \
 	  if [ $$filename = $(itweb_settings) ] ; then \
 	    export MAIN_CLASS=net.sourceforge.jnlp.controlpanel.CommandLine ; \
-	    export BIN_LOCATION=$(bindir)/$(itweb_settings).sh ; \
+	    export BIN_LOCATION=$(bindir)/$(itweb_settings) ; \
 	    export PROGRAM_NAME=$(itweb_settings) ; \
 	  fi ; \
 	  if [ $$filename = $(policyeditor) ] ; then \
 	    export MAIN_CLASS=net.sourceforge.jnlp.security.policyeditor.PolicyEditor ; \
-	    export BIN_LOCATION=$(bindir)/$(policyeditor).sh ; \
+	    export BIN_LOCATION=$(bindir)/$(policyeditor) ; \
 	    export PROGRAM_NAME=$(policyeditor) ; \
 	  fi ; \
 	  $(CARGO) test ; \
@@ -945,6 +945,50 @@
 	  mv $@ $@.broken ; \
 	fi; \
 	exit $$r
+
+# https://github.com/SimonKagstrom/kcov/
+# build is not part of upstream, declaring
+rust-code-coverage:
+	kcov="none" ; \
+	if [ -f $(KCOV)/kcov ] ; then \
+	  kcov=$(KCOV)/kcov ; \
+	elif [ -f $(KCOV)/bin/kcov ] ; then \
+	  kcov=$(KCOV)/bin/kcov ; \
+	elif [ -f $(KCOV)/build/kcov ] ; then \
+	  kcov=$(KCOV)/build/kcov ; \
+	elif [ -f $(KCOV)/build/src/kcov ] ; then \
+	  kcov=$(KCOV)/build/src/kcov ; \
+	else \
+	  mkdir $(KCOV)/build ; \
+	  pushd $(KCOV)/build ; \
+	  cmake .. ; \
+	  make ; \
+	  popd ; \
+	  kcov=$(KCOV)/build/src/kcov ; \
+	fi ; \
+	export ITW_TMP_REPLACEMENT=$(TESTS_DIR)/rust_tests_tmp ; \
+	mkdir -p $$ITW_TMP_REPLACEMENT; \
+	srcs=$(TOP_SRC_DIR)/rust-launcher ; \
+	outs=$(TOP_BUILD_DIR)/launcher.in.codecoverage  ; \
+	rm -rvf $$outs  ; \
+	cp -r $$srcs $$outs  ; \
+	pushd $$outs ; \
+	  export JAVA=$(JAVA) ; \
+	  export JRE=$(SYSTEM_JRE_DIR) ; \
+	  export SPLASH_PNG=$(SPLASH_PNG) ; \
+	  export ITW_LIBS=$(ITW_LIBS) ; \
+	  export PLUGIN_JAR=$(PLUGIN_JAR) ; \
+	  export NETX_JAR=$(NETX_JAR) ; \
+	  export JSOBJECT_JAR=$(JSOBJECT_JAR) ; \
+	  export TAGSOUP_JAR=$(TAGSOUP_JAR) ; \
+	  export RHINO_JAR=$(RHINO_JAR) ; \
+	  export MAIN_CLASS=net.sourceforge.jnlp.runtime.Boot ; \
+	  export BIN_LOCATION=$(bindir)/none ; \
+	  export PROGRAM_NAME=test ; \
+	  $(CARGO) test  --no-run ; \
+	popd ; \
+	rm -fv $(TOP_BUILD_DIR)/launcher.in.codecoverage/target/debug/launcher-*.d ; \
+	$$kcov $$outs $(TOP_BUILD_DIR)/launcher.in.codecoverage/target/debug/launcher-*
 endif
 
 if ENABLE_SHELL_LAUNCHERS
--- a/acinclude.m4	Wed Jan 09 16:16:54 2019 +0100
+++ b/acinclude.m4	Mon Jan 14 09:48:26 2019 +0100
@@ -1126,3 +1126,24 @@
     AC_SUBST(WIX_TOOLSET_DIR)
   fi
 ])
+
+
+AC_DEFUN([IT_CHECK_WITH_KCOV],
+[
+  AC_MSG_CHECKING([whether enable rust code coverage])
+  AC_ARG_WITH([kcov],
+	      [AS_HELP_STRING(--with-kcov,location of kcov directory)],
+  [
+    KCOV="${withval}"
+  ],
+  [ 
+    KCOV="no"
+  ])
+  AC_MSG_RESULT([${KCOV}])
+  if ! test "x${KCOV}" = "xno" ; then
+    if ! test -d "${KCOV}" ; then
+      AC_MSG_ERROR("kcov schould point to direcotry or - default - no")
+    fi
+  fi
+  AC_SUBST([KCOV])
+])
--- a/configure.ac	Wed Jan 09 16:16:54 2019 +0100
+++ b/configure.ac	Mon Jan 14 09:48:26 2019 +0100
@@ -82,6 +82,8 @@
 AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
 AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
 
+IT_CHECK_WITH_KCOV
+
 AC_MSG_CHECKING([how to search for libraries in native launchers])
 AC_ARG_WITH([itw-libs],
 	      [AS_HELP_STRING([--with-itw-libs],