summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2012-07-05 21:23:01 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2012-07-05 21:23:01 +0000
commitbc13aadd2b086c8b7bb3ac0e7e00f6640ed72f46 (patch)
treefd3198845d7db2f13e160797939e89f8272153fe
parentRe-sign manifest. (diff)
downloadhistorical-bc13aadd2b086c8b7bb3ac0e7e00f6640ed72f46.tar.gz
historical-bc13aadd2b086c8b7bb3ac0e7e00f6640ed72f46.tar.bz2
historical-bc13aadd2b086c8b7bb3ac0e7e00f6640ed72f46.zip
Add support for running rspec while respecting some common variables (TEST_VERBOSE and NOCOLOR) in ruby-ng; then use this with a new variable in ruby-fakegem.
-rw-r--r--eclass/ChangeLog8
-rw-r--r--eclass/ruby-fakegem.eclass66
-rw-r--r--eclass/ruby-ng.eclass33
3 files changed, 87 insertions, 20 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index d66718dfa66a..3c4cf69a5017 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.335 2012/07/05 20:07:47 sera Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.336 2012/07/05 21:23:01 flameeyes Exp $
+
+ 05 Jul 2012; Diego E. Pettenò <flameeyes@gentoo.org> ruby-fakegem.eclass,
+ ruby-ng.eclass:
+ Add support for running rspec while respecting some common variables
+ (TEST_VERBOSE and NOCOLOR) in ruby-ng; then use this with a new variable in
+ ruby-fakegem.
05 Jul 2012; Ralph Sennhauser <sera@gentoo.org> java-utils-2.eclass:
Remove java-pkg_ensure-gcj and java-pkg_ensure-test. #261562 #278965
diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
index 831e1a593abc..c050c58052ba 100644
--- a/eclass/ruby-fakegem.eclass
+++ b/eclass/ruby-fakegem.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.32 2011/12/05 12:24:33 graaff Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.33 2012/07/05 21:23:01 flameeyes Exp $
# @ECLASS: ruby-fakegem.eclass
# @MAINTAINER:
@@ -30,9 +30,18 @@ inherit ruby-ng
# Specify the rake(1) task to run to generate documentation.
# RUBY_FAKEGEM_TASK_DOC="rdoc"
+# @ECLASS-VARIABLE: RUBY_FAKEGEM_RECIPE_TEST
+# @DESCRIPTION:
+# Specify one of the default testing function for ruby-fakegem:
+# - rake (default; see also RUBY_FAKEGEM_TASK_TEST)
+# - rspec (calls ruby-ng_rspec, adds dev-ruby/rspec:2 to the dependencies)
+# - none
+# RUBY_FAKEGEM_RECIPE_TEST="rake"
+
# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_TEST
# @DESCRIPTION:
-# Specify the rake(1) task used for executing tests.
+# Specify the rake(1) task used for executing tests. Only valid
+# if RUBY_FAKEGEM_RECIPE_TEST is set to "rake" (the default).
# RUBY_FAKEGEM_TASK_TEST="test"
# @ECLASS-VARIABLE: RUBY_FAKEGEM_DOCDIR
@@ -73,6 +82,7 @@ RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV/_pre/.pre}}"
RUBY_FAKEGEM_SUFFIX="${RUBY_FAKEGEM_SUFFIX:-}"
RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}"
+RUBY_FAKEGEM_RECIPE_TEST="${RUBY_FAKEGEM_RECIPE_TEST-rake}"
RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}"
RUBY_FAKEGEM_BINWRAP="${RUBY_FAKEGEM_BINWRAP-*}"
@@ -86,10 +96,21 @@ if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]]; then
IUSE="$IUSE doc"
fi
-if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then
- IUSE="$IUSE test"
- ruby_add_bdepend "test? ( dev-ruby/rake )"
-fi
+[[ ${RUBY_FAKEGEM_TASK_TEST} == "" ]] && RUBY_FAKEGEM_RECIPE_TEST="none"
+
+case ${RUBY_FAKEGEM_RECIPE_TEST} in
+ rake)
+ IUSE+=" test"
+ ruby_add_bdepend "test? ( dev-ruby/rake )"
+ ;;
+ rspec)
+ IUSE+=" test"
+ ruby_add_bdepend "test? ( dev-ruby/rspec:2 )"
+ ;;
+ *)
+ RUBY_FAKEGEM_RECIPE_TEST="none"
+ ;;
+esac
SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${RUBY_FAKEGEM_SUFFIX:+-${RUBY_FAKEGEM_SUFFIX}}.gem"
@@ -216,7 +237,7 @@ ruby_fakegem_genspec() {
# so better taking this into consideration.
local quoted_description=${DESCRIPTION//\"/\\\"}
cat - > $1 <<EOF
-# generated by ruby-fakegem.eclass $Revision: 1.32 $
+# generated by ruby-fakegem.eclass $Revision: 1.33 $
Gem::Specification.new do |s|
s.name = "${RUBY_FAKEGEM_NAME}"
s.version = "${RUBY_FAKEGEM_VERSION}"
@@ -266,7 +287,7 @@ ruby_fakegem_binwrapper() {
#!${rubycmd}
# This is a simplified version of the RubyGems wrapper
#
-# Generated by ruby-fakegem.eclass $Revision: 1.32 $
+# Generated by ruby-fakegem.eclass $Revision: 1.33 $
require 'rubygems'
@@ -346,17 +367,26 @@ all_ruby_compile() {
# @DESCRIPTION:
# Run tests for the package for each ruby target if the test task is defined.
each_fakegem_test() {
- local rubyflags=
- ${RUBY} ${rubyflags} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
+ case ${RUBY_FAKEGEM_RECIPE_TEST} in
+ rake)
+ ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
+ ;;
+ rspec)
+ ruby-ng_rspec
+ ;;
+ none)
+ ewarn "each_fakegem_test called, but \${RUBY_FAKEGEM_RECIPE_TEST} is 'none'"
+ ;;
+ esac
}
-if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then
- # @FUNCTION: each_ruby_test
- # @DESCRIPTION:
- # Run the tests for this package.
- each_ruby_test() {
- each_fakegem_test
- }
+if [[ ${RUBY_FAKEGEM_RECIPE_TEST} != none ]]; then
+ # @FUNCTION: each_ruby_test
+ # @DESCRIPTION:
+ # Run the tests for this package.
+ each_ruby_test() {
+ each_fakegem_test
+ }
fi
# @FUNCTION: each_fakegem_install
diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
index bd10fc39b12a..149e483782a9 100644
--- a/eclass/ruby-ng.eclass
+++ b/eclass/ruby-ng.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.46 2012/06/02 19:16:31 zmedico Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.47 2012/07/05 21:23:01 flameeyes Exp $
# @ECLASS: ruby-ng.eclass
# @MAINTAINER:
@@ -627,3 +627,34 @@ ruby_get_implementation() {
;;
esac
}
+
+# @FUNCTION: ruby-ng_rspec
+# @DESCRIPTION:
+# This is simply a wrapper around the rspec command (executed by $RUBY})
+# which also respects TEST_VERBOSE and NOCOLOR environment variables.
+ruby-ng_rspec() {
+ if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
+ ewarn "Missing dev-ruby/rspec in \${DEPEND}"
+ fi
+
+ local rspec_params=
+ case ${NOCOLOR} in
+ 1|yes|true)
+ rspec_params+=" --no-color"
+ ;;
+ *)
+ rspec_params+=" --color"
+ ;;
+ esac
+
+ case ${TEST_VERBOSE} in
+ 1|yes|true)
+ rspec_params+=" --format documentation"
+ ;;
+ *)
+ rspec_params+=" --format progress"
+ ;;
+ esac
+
+ ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed"
+}