From: Marcel Denia Date: Tue, 19 Aug 2014 22:31:31 +0000 (+0200) Subject: perl: Add basic test support X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=95058be6053c4c2fc5cf0bcbc869f58a7990848a;p=feed%2Fpackages.git perl: Add basic test support Signed-off-by: Marcel Denia --- diff --git a/lang/perl/Config.in b/lang/perl/Config.in new file mode 100644 index 0000000000..1af89f347f --- /dev/null +++ b/lang/perl/Config.in @@ -0,0 +1,12 @@ +menu "Configuration" + depends on PACKAGE_perl + +config PERL_TESTS + bool "Include perl tests" + default n + help + Include test suites for all perl packages. + This will make perl related packages much bigger, so + use with care. + +endmenu diff --git a/lang/perl/Makefile b/lang/perl/Makefile index bef6c211d5..3467c160ea 100644 --- a/lang/perl/Makefile +++ b/lang/perl/Makefile @@ -44,6 +44,9 @@ endif TARGET_CFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CFLAGS)) TARGET_CPPFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CPPFLAGS)) +# A list of disabled testss +PERL_DISABLEDTESTS:= + include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk include perlmod.mk @@ -63,6 +66,10 @@ define Package/perl/description and is widely used to program web applications of all needs. endef +define Package/perl/config + source "$(SOURCE)/Config.in" +endef + # Static host perl define Host/Configure ( cd $(HOST_BUILD_DIR); ./Configure -der -Uusedl -Duserelocatableinc -Dprefix=$(HOST_PERL_PREFIX) ) @@ -128,3 +135,37 @@ $(eval $(call BuildPackage,perl)) $(eval $(call HostBuild)) -include perlbase.mk + +# A helper package that includes all sort of supplementary files for tests +define Package/perl-tests-common +$(call Package/perlbase-template) +TITLE:=Common test support files +DEPENDS:=@PERL_TESTS +endef + +define Package/perl-tests-common/install + $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR) + $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)/Porting + $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)/regen + $(INSTALL_DIR) $(1)/usr/lib/perl5/5.20/XS + $(INSTALL_DIR) $(1)/usr/lib/perl5/5.20/auto/XS + $(INSTALL_DIR) $(1)/usr/lib/perl5/5.20/unicore + + $(CP) $(PKG_BUILD_DIR)/t $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/Porting $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/regen $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/MANIFEST $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/TestInit.pm $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/vutil.c $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/vxs.inc $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/lib/XS $(1)/usr/lib/perl5/5.20/ + $(CP) $(PKG_BUILD_DIR)/lib/auto/XS $(1)/usr/lib/perl5/5.20/auto + $(CP) $(PKG_BUILD_DIR)/lib/vmsish.pm $(1)/usr/lib/perl5/5.20/ + $(CP) $(PKG_BUILD_DIR)/lib/unicore/TestProp.pl $(1)/usr/lib/perl5/5.20/unicore + $(CP) files/perl-run_tests.sh $(1)/$(PERL_TESTSDIR)/run_tests.sh + sed -e 's!%%PERL_DISABLEDTESTS%%!$(PERL_DISABLEDTESTS)!' -i $(1)/$(PERL_TESTSDIR)/run_tests.sh + $(CP) $(PKG_BUILD_DIR)/config_h.SH $(1)/$(PERL_TESTSDIR) + $(CP) $(PKG_BUILD_DIR)/perl.h $(1)/$(PERL_TESTSDIR) +endef + +$(eval $(call BuildPackage,perl-tests-common)) diff --git a/lang/perl/files/perl-run_tests.sh b/lang/perl/files/perl-run_tests.sh new file mode 100755 index 0000000000..af6a39c94d --- /dev/null +++ b/lang/perl/files/perl-run_tests.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +PERL_TESTSDIR="/usr/share/perl/perl-tests" +PERL_LIBDIR="/usr/lib/perl5/5.20/" +PERL_DISABLEDTESTS="%%PERL_DISABLEDTESTS%%" + +if [ ! -f "$PERL_TESTSDIR/__prepared" ]; then + ln -s "$PERL_LIBDIR" "$PERL_TESTSDIR/lib" + ln -s /usr/bin/perl "$PERL_TESTSDIR/perl" + ln -s /usr/bin/perl "$PERL_TESTSDIR/t/perl" + touch "$PERL_TESTSDIR/__prepared" + + for i in $PERL_DISABLEDTESTS; do + echo "Disabling $i tests" + sed 's!^'$i'.*$!!' -i $PERL_TESTSDIR/MANIFEST + done + + cat $PERL_TESTSDIR/MANIFEST | grep -v '^$' > $PERL_TESTSDIR/MANIFEST_NEW + rm $PERL_TESTSDIR/MANIFEST + mv $PERL_TESTSDIR/MANIFEST_NEW $PERL_TESTSDIR/MANIFEST +fi + +cd "$PERL_TESTSDIR/t" +./perl TEST diff --git a/lang/perl/perlmod.mk b/lang/perl/perlmod.mk index 3c3d56720a..928944c5b8 100644 --- a/lang/perl/perlmod.mk +++ b/lang/perl/perlmod.mk @@ -11,6 +11,9 @@ PERL_CMD:=$(STAGING_DIR_HOST)/usr/bin/perl5.20.0 # Module install prefix PERL_SITELIB:=/usr/lib/perl5/5.20 +PERL_TESTSDIR:=/usr/share/perl/perl-tests +PERLBASE_TESTSDIR:=/usr/share/perl/perlbase-tests +PERLMOD_TESTSDIR:=/usr/share/perl/perlmod-tests define perlmod/host/relink rm -f $(1)/Makefile.aperl @@ -105,7 +108,7 @@ define perlmod/Compile install endef -define perlmod/Install +define perlmod/Install/NoStrip $(INSTALL_DIR) $(strip $(1))$(PERL_SITELIB) (cd $(PKG_INSTALL_DIR)$(PERL_SITELIB) && \ rsync --relative -rlHp --itemize-changes \ @@ -116,6 +119,11 @@ define perlmod/Install $(strip $(2)) $(strip $(1))$(PERL_SITELIB)) chmod -R u+w $(strip $(1))$(PERL_SITELIB) +endef + + +define perlmod/Install + $(call perlmod/Install/NoStrip,$(1),$(2),$(3)) @echo "---> Stripping modules in: $(strip $(1))$(PERL_SITELIB)" find $(strip $(1))$(PERL_SITELIB) -name \*.pm -or -name \*.pl | \ @@ -125,3 +133,23 @@ define perlmod/Install -e '/^#$$$$/d' \ -e '/^#[^!"'"'"']/d' endef + +# You probably don't want to use this directly. Look at perlmod/InstallTests +define perlmod/_InstallTests + $(INSTALL_DIR) $(strip $(1)) + (cd $(PKG_BUILD_DIR)/$(2) && \ + rsync --relative -rlHp --itemize-changes \ + --exclude=.packlist \ + --prune-empty-dirs \ + $(strip $(3)) $(strip $(1))) + + chmod -R u+w $(strip $(1)) +endef + +define perlmod/InstallBaseTests + $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),,$(2))) +endef + +define perlmod/InstallTests + $(if $(CONFIG_PERL_TESTS),$(call perlmod/_InstallTests,$(1)$(PERL_TESTSDIR),$(2),$(3))) +endef