/[gentoo-x86]/eclass/ruby-ng.eclass
Gentoo

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.52 - (show annotations) (download)
Sun Jun 23 14:56:07 2013 UTC (9 months, 3 weeks ago) by graaff
Branch: MAIN
Changes since 1.51: +7 -2 lines
Add support for ruby20.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.51 2012/09/27 16:35:41 axs Exp $
4
5 # @ECLASS: ruby-ng.eclass
6 # @MAINTAINER:
7 # Ruby herd <ruby@gentoo.org>
8 # @AUTHOR:
9 # Author: Diego E. Pettenò <flameeyes@gentoo.org>
10 # Author: Alex Legler <a3li@gentoo.org>
11 # Author: Hans de Graaff <graaff@gentoo.org>
12 # @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots.
13 # @DESCRIPTION:
14 # The Ruby eclass is designed to allow an easier installation of Ruby packages
15 # and their incorporation into the Gentoo Linux system.
16 #
17 # Currently available targets are:
18 # * ruby18 - Ruby (MRI) 1.8.x
19 # * ruby19 - Ruby (MRI) 1.9.x
20 # * ruby20 - Ruby (MRI) 2.0.x
21 # * ree18 - Ruby Enterprise Edition 1.8.x
22 # * jruby - JRuby
23 # * rbx - Rubinius
24 #
25 # This eclass does not define the implementation of the configure,
26 # compile, test, or install phases. Instead, the default phases are
27 # used. Specific implementations of these phases can be provided in
28 # the ebuild either to be run for each Ruby implementation, or for all
29 # Ruby implementations, as follows:
30 #
31 # * each_ruby_configure
32 # * all_ruby_configure
33
34 # @ECLASS-VARIABLE: USE_RUBY
35 # @REQUIRED
36 # @DESCRIPTION:
37 # This variable contains a space separated list of targets (see above) a package
38 # is compatible to. It must be set before the `inherit' call. There is no
39 # default. All ebuilds are expected to set this variable.
40
41 # @ECLASS-VARIABLE: RUBY_PATCHES
42 # @DEFAULT_UNSET
43 # @DESCRIPTION:
44 # A String or Array of filenames of patches to apply to all implementations.
45
46 # @ECLASS-VARIABLE: RUBY_OPTIONAL
47 # @DESCRIPTION:
48 # Set the value to "yes" to make the dependency on a Ruby interpreter
49 # optional and then ruby_implementations_depend() to help populate
50 # DEPEND and RDEPEND.
51
52 # @ECLASS-VARIABLE: RUBY_S
53 # @DEFAULT_UNSET
54 # @DESCRIPTION:
55 # If defined this variable determines the source directory name after
56 # unpacking. This defaults to the name of the package. Note that this
57 # variable supports a wildcard mechanism to help with github tarballs
58 # that contain the commit hash as part of the directory name.
59
60 # @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
61 # @DEFAULT_UNSET
62 # @DESCRIPTION:
63 # If defined this variable contains a whitelist of shared objects that
64 # are allowed to exist even if they don't link to libruby. This avoids
65 # the QA check that makes this mandatory. This is most likely not what
66 # you are looking for if you get the related "Missing links" QA warning,
67 # since the proper fix is almost always to make sure the shared object
68 # is linked against libruby. There are cases were this is not the case
69 # and the shared object is generic code to be used in some other way
70 # (e.g. selenium's firefox driver extension). When set this argument is
71 # passed to "grep -E" to remove reporting of these shared objects.
72
73 inherit eutils java-utils-2 multilib toolchain-funcs
74
75 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
76
77 case ${EAPI} in
78 0|1)
79 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
80 2|3) ;;
81 4|5)
82 # S is no longer automatically assigned when it doesn't exist.
83 S="${WORKDIR}"
84 ;;
85 *)
86 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
87 esac
88
89 # @FUNCTION: ruby_implementation_depend
90 # @USAGE: target [comparator [version]]
91 # @RETURN: Package atom of a Ruby implementation to be used in dependencies.
92 # @DESCRIPTION:
93 # This function returns the formal package atom for a Ruby implementation.
94 #
95 # `target' has to be one of the valid values for USE_RUBY (see above)
96 #
97 # Set `comparator' and `version' to include a comparator (=, >=, etc.) and a
98 # version string to the returned string
99 ruby_implementation_depend() {
100 local rubypn=
101 local rubyslot=
102
103 case $1 in
104 ruby18)
105 rubypn="dev-lang/ruby"
106 rubyslot=":1.8"
107 ;;
108 ruby19)
109 rubypn="dev-lang/ruby"
110 rubyslot=":1.9"
111 ;;
112 ruby20)
113 rubypn="dev-lang/ruby"
114 rubyslot=":2.0"
115 ;;
116 ree18)
117 rubypn="dev-lang/ruby-enterprise"
118 rubyslot=":1.8"
119 ;;
120 jruby)
121 rubypn="dev-java/jruby"
122 rubyslot=""
123 ;;
124 rbx)
125 rubypn="dev-lang/rubinius"
126 rubyslot=""
127 ;;
128 *) die "$1: unknown Ruby implementation"
129 esac
130
131 echo "$2${rubypn}$3${rubyslot}"
132 }
133
134 # @FUNCTION: ruby_samelib
135 # @RETURN: use flag string with current ruby implementations
136 # @DESCRIPTION:
137 # Convenience function to output the use dependency part of a
138 # dependency. Used as a building block for ruby_add_rdepend() and
139 # ruby_add_bdepend(), but may also be useful in an ebuild to specify
140 # more complex dependencies.
141 ruby_samelib() {
142 local res=
143 for _ruby_implementation in $USE_RUBY; do
144 has -${_ruby_implementation} $@ || \
145 res="${res}ruby_targets_${_ruby_implementation}?,"
146 done
147
148 echo "[${res%,}]"
149 }
150
151 _ruby_atoms_samelib_generic() {
152 eshopts_push -o noglob
153 echo "RUBYTARGET? ("
154 for token in $*; do
155 case "$token" in
156 "||" | "(" | ")" | *"?")
157 echo "${token}" ;;
158 *])
159 echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
160 *)
161 echo "${token}[RUBYTARGET]" ;;
162 esac
163 done
164 echo ")"
165 eshopts_pop
166 }
167
168 # @FUNCTION: ruby_implementation_command
169 # @RETURN: the path to the given ruby implementation
170 # @DESCRIPTION:
171 # Not all implementations have the same command basename as the
172 # target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
173 # respectively. This function translate between the two
174 ruby_implementation_command() {
175 local _ruby_name=$1
176
177 # Add all USE_RUBY values where the flag name diverts from the binary here
178 case $1 in
179 ree18)
180 _ruby_name=rubyee18
181 ;;
182 esac
183
184 echo $(type -p ${_ruby_name} 2>/dev/null)
185 }
186
187 _ruby_atoms_samelib() {
188 local atoms=$(_ruby_atoms_samelib_generic "$*")
189
190 for _ruby_implementation in $USE_RUBY; do
191 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
192 done
193 }
194
195 _ruby_wrap_conditions() {
196 local conditions="$1"
197 local atoms="$2"
198
199 for condition in $conditions; do
200 atoms="${condition}? ( ${atoms} )"
201 done
202
203 echo "$atoms"
204 }
205
206 # @FUNCTION: ruby_add_rdepend
207 # @USAGE: dependencies
208 # @DESCRIPTION:
209 # Adds the specified dependencies, with use condition(s) to RDEPEND,
210 # taking the current set of ruby targets into account. This makes sure
211 # that all ruby dependencies of the package are installed for the same
212 # ruby targets. Use this function for all ruby dependencies instead of
213 # setting RDEPEND yourself. The list of atoms uses the same syntax as
214 # normal dependencies.
215 #
216 # Note: runtime dependencies are also added as build-time test
217 # dependencies.
218 ruby_add_rdepend() {
219 case $# in
220 1) ;;
221 2)
222 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF"
223 ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")"
224 return
225 ;;
226 *)
227 die "bad number of arguments to $0"
228 ;;
229 esac
230
231 local dependency=$(_ruby_atoms_samelib "$1")
232
233 RDEPEND="${RDEPEND} $dependency"
234
235 # Add the dependency as a test-dependency since we're going to
236 # execute the code during test phase.
237 DEPEND="${DEPEND} test? ( ${dependency} )"
238 has test "$IUSE" || IUSE="${IUSE} test"
239 }
240
241 # @FUNCTION: ruby_add_bdepend
242 # @USAGE: dependencies
243 # @DESCRIPTION:
244 # Adds the specified dependencies, with use condition(s) to DEPEND,
245 # taking the current set of ruby targets into account. This makes sure
246 # that all ruby dependencies of the package are installed for the same
247 # ruby targets. Use this function for all ruby dependencies instead of
248 # setting DEPEND yourself. The list of atoms uses the same syntax as
249 # normal dependencies.
250 ruby_add_bdepend() {
251 case $# in
252 1) ;;
253 2)
254 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF"
255 ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")"
256 return
257 ;;
258 *)
259 die "bad number of arguments to $0"
260 ;;
261 esac
262
263 local dependency=$(_ruby_atoms_samelib "$1")
264
265 DEPEND="${DEPEND} $dependency"
266 RDEPEND="${RDEPEND}"
267 }
268
269 # @FUNCTION: ruby_get_use_implementations
270 # @DESCRIPTION:
271 # Gets an array of ruby use targets enabled by the user
272 ruby_get_use_implementations() {
273 local i implementation
274 for implementation in ${USE_RUBY}; do
275 use ruby_targets_${implementation} && i+=" ${implementation}"
276 done
277 echo $i
278 }
279
280 # @FUNCTION: ruby_get_use_targets
281 # @DESCRIPTION:
282 # Gets an array of ruby use targets that the ebuild sets
283 ruby_get_use_targets() {
284 local t implementation
285 for implementation in ${USE_RUBY}; do
286 t+=" ruby_targets_${implementation}"
287 done
288 echo $t
289 }
290
291 # @FUNCTION: ruby_implementations_depend
292 # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
293 # @DESCRIPTION:
294 # Produces the dependency string for the various implementations of ruby
295 # which the package is being built against. This should not be used when
296 # RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
297 # confuse this function with ruby_implementation_depend().
298 #
299 # @EXAMPLE:
300 # EAPI=4
301 # RUBY_OPTIONAL=yes
302 #
303 # inherit ruby-ng
304 # ...
305 # DEPEND="ruby? ( $(ruby_implementations_depend) )"
306 # RDEPEND="${DEPEND}"
307 ruby_implementations_depend() {
308 local depend
309 for _ruby_implementation in ${USE_RUBY}; do
310 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
311 done
312 echo "${depend}"
313 }
314
315 IUSE+=" $(ruby_get_use_targets)"
316 # If you specify RUBY_OPTIONAL you also need to take care of
317 # ruby useflag and dependency.
318 if [[ ${RUBY_OPTIONAL} != yes ]]; then
319 DEPEND="${DEPEND} $(ruby_implementations_depend)"
320 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
321
322 case ${EAPI:-0} in
323 4|5)
324 REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
325 ;;
326 esac
327 fi
328
329 _ruby_invoke_environment() {
330 old_S=${S}
331 case ${EAPI} in
332 4|5)
333 if [ -z ${RUBY_S} ]; then
334 sub_S=${P}
335 else
336 sub_S=${RUBY_S}
337 fi
338 ;;
339 *)
340 sub_S=${S#${WORKDIR}/}
341 ;;
342 esac
343
344 # Special case, for the always-lovely GitHub fetches. With this,
345 # we allow the star glob to just expand to whatever directory it's
346 # called.
347 if [[ ${sub_S} = *"*"* ]]; then
348 case ${EAPI} in
349 2|3)
350 #The old method of setting S depends on undefined package
351 # manager behaviour, so encourage upgrading to EAPI=4.
352 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
353 ;;
354 esac
355 pushd "${WORKDIR}"/all &>/dev/null
356 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
357 popd &>/dev/null
358 fi
359
360 environment=$1; shift
361
362 my_WORKDIR="${WORKDIR}"/${environment}
363 S="${my_WORKDIR}"/"${sub_S}"
364
365 if [[ -d "${S}" ]]; then
366 pushd "$S" &>/dev/null
367 elif [[ -d "${my_WORKDIR}" ]]; then
368 pushd "${my_WORKDIR}" &>/dev/null
369 else
370 pushd "${WORKDIR}" &>/dev/null
371 fi
372
373 ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment"
374 "$@"
375 popd &>/dev/null
376
377 S=${old_S}
378 }
379
380 _ruby_each_implementation() {
381 local invoked=no
382 for _ruby_implementation in ${USE_RUBY}; do
383 # only proceed if it's requested
384 use ruby_targets_${_ruby_implementation} || continue
385
386 RUBY=$(ruby_implementation_command ${_ruby_implementation})
387 invoked=yes
388
389 if [[ -n "$1" ]]; then
390 _ruby_invoke_environment ${_ruby_implementation} "$@"
391 fi
392
393 unset RUBY
394 done
395
396 if [[ ${invoked} == "no" ]]; then
397 eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
398 eerror "Compatible targets for this package are: ${USE_RUBY}"
399 eerror
400 eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
401 eerror
402 die "No compatible Ruby target selected."
403 fi
404 }
405
406 # @FUNCTION: ruby-ng_pkg_setup
407 # @DESCRIPTION:
408 # Check whether at least one ruby target implementation is present.
409 ruby-ng_pkg_setup() {
410 # This only checks that at least one implementation is present
411 # before doing anything; by leaving the parameters empty we know
412 # it's a special case.
413 _ruby_each_implementation
414
415 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
416 }
417
418 # @FUNCTION: ruby-ng_src_unpack
419 # @DESCRIPTION:
420 # Unpack the source archive.
421 ruby-ng_src_unpack() {
422 mkdir "${WORKDIR}"/all
423 pushd "${WORKDIR}"/all &>/dev/null
424
425 # We don't support an each-unpack, it's either all or nothing!
426 if type all_ruby_unpack &>/dev/null; then
427 _ruby_invoke_environment all all_ruby_unpack
428 else
429 [[ -n ${A} ]] && unpack ${A}
430 fi
431
432 popd &>/dev/null
433 }
434
435 _ruby_apply_patches() {
436 for patch in "${RUBY_PATCHES[@]}"; do
437 if [ -f "${patch}" ]; then
438 epatch "${patch}"
439 elif [ -f "${FILESDIR}/${patch}" ]; then
440 epatch "${FILESDIR}/${patch}"
441 else
442 die "Cannot find patch ${patch}"
443 fi
444 done
445
446 # This is a special case: instead of executing just in the special
447 # "all" environment, this will actually copy the effects on _all_
448 # the other environments, and is thus executed before the copy
449 type all_ruby_prepare &>/dev/null && all_ruby_prepare
450 }
451
452 _ruby_source_copy() {
453 # Until we actually find a reason not to, we use hardlinks, this
454 # should reduce the amount of disk space that is wasted by this.
455 cp -prl all ${_ruby_implementation} \
456 || die "Unable to copy ${_ruby_implementation} environment"
457 }
458
459 # @FUNCTION: ruby-ng_src_prepare
460 # @DESCRIPTION:
461 # Apply patches and prepare versions for each ruby target
462 # implementation. Also carry out common clean up tasks.
463 ruby-ng_src_prepare() {
464 # Way too many Ruby packages are prepared on OSX without removing
465 # the extra data forks, we do it here to avoid repeating it for
466 # almost every other ebuild.
467 find . -name '._*' -delete
468
469 _ruby_invoke_environment all _ruby_apply_patches
470
471 _PHASE="source copy" \
472 _ruby_each_implementation _ruby_source_copy
473
474 if type each_ruby_prepare &>/dev/null; then
475 _ruby_each_implementation each_ruby_prepare
476 fi
477 }
478
479 # @FUNCTION: ruby-ng_src_configure
480 # @DESCRIPTION:
481 # Configure the package.
482 ruby-ng_src_configure() {
483 if type each_ruby_configure &>/dev/null; then
484 _ruby_each_implementation each_ruby_configure
485 fi
486
487 type all_ruby_configure &>/dev/null && \
488 _ruby_invoke_environment all all_ruby_configure
489 }
490
491 # @FUNCTION: ruby-ng_src_compile
492 # @DESCRIPTION:
493 # Compile the package.
494 ruby-ng_src_compile() {
495 if type each_ruby_compile &>/dev/null; then
496 _ruby_each_implementation each_ruby_compile
497 fi
498
499 type all_ruby_compile &>/dev/null && \
500 _ruby_invoke_environment all all_ruby_compile
501 }
502
503 # @FUNCTION: ruby-ng_src_test
504 # @DESCRIPTION:
505 # Run tests for the package.
506 ruby-ng_src_test() {
507 if type each_ruby_test &>/dev/null; then
508 _ruby_each_implementation each_ruby_test
509 fi
510
511 type all_ruby_test &>/dev/null && \
512 _ruby_invoke_environment all all_ruby_test
513 }
514
515 _each_ruby_check_install() {
516 local scancmd=scanelf
517 # we have a Mach-O object here
518 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
519
520 has "${EAPI}" 2 && ! use prefix && EPREFIX=
521
522 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
523 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
524 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
525 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
526
527 # Look for wrong files in sitedir
528 # if [[ -d "${D}${sitedir}" ]]; then
529 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
530 # if [[ -n ${f} ]]; then
531 # eerror "Found files in sitedir, outsite sitelibdir:"
532 # eerror "${f}"
533 # die "Misplaced files in sitedir"
534 # fi
535 # fi
536
537 # The current implementation lacks libruby (i.e.: jruby)
538 [[ -z ${libruby_soname} ]] && return 0
539
540 # Check also the gems directory, since we could be installing compiled
541 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
542 # that's what changes between two implementations (otherwise you'd get false
543 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
544 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
545 | fgrep -v "${libruby_soname}" \
546 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
547 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
548
549 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
550 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
551 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
552 die "Missing links to ${libruby_soname}"
553 fi
554 }
555
556 # @FUNCTION: ruby-ng_src_install
557 # @DESCRIPTION:
558 # Install the package for each ruby target implementation.
559 ruby-ng_src_install() {
560 if type each_ruby_install &>/dev/null; then
561 _ruby_each_implementation each_ruby_install
562 fi
563
564 type all_ruby_install &>/dev/null && \
565 _ruby_invoke_environment all all_ruby_install
566
567 _PHASE="check install" \
568 _ruby_each_implementation _each_ruby_check_install
569 }
570
571 # @FUNCTION: ruby_rbconfig_value
572 # @USAGE: rbconfig item
573 # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
574 ruby_rbconfig_value() {
575 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
576 }
577
578 # @FUNCTION: doruby
579 # @USAGE: file [file...]
580 # @DESCRIPTION:
581 # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
582 doruby() {
583 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
584 has "${EAPI}" 2 && ! use prefix && EPREFIX=
585 ( # don't want to pollute calling env
586 sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
587 insinto ${sitelibdir#${EPREFIX}}
588 insopts -m 0644
589 doins "$@"
590 ) || die "failed to install $@"
591 }
592
593 # @FUNCTION: ruby_get_libruby
594 # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
595 ruby_get_libruby() {
596 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
597 }
598
599 # @FUNCTION: ruby_get_hdrdir
600 # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
601 ruby_get_hdrdir() {
602 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
603
604 if [[ "${rubyhdrdir}" = "nil" ]] ; then
605 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
606 fi
607
608 echo "${rubyhdrdir}"
609 }
610
611 # @FUNCTION: ruby_get_version
612 # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
613 ruby_get_version() {
614 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
615
616 echo $(${ruby} -e 'puts RUBY_VERSION')
617 }
618
619 # @FUNCTION: ruby_get_implementation
620 # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
621 ruby_get_implementation() {
622 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
623
624 case $(${ruby} --version) in
625 *Enterprise*)
626 echo "ree"
627 ;;
628 *jruby*)
629 echo "jruby"
630 ;;
631 *rubinius*)
632 echo "rbx"
633 ;;
634 *)
635 echo "mri"
636 ;;
637 esac
638 }
639
640 # @FUNCTION: ruby-ng_rspec
641 # @DESCRIPTION:
642 # This is simply a wrapper around the rspec command (executed by $RUBY})
643 # which also respects TEST_VERBOSE and NOCOLOR environment variables.
644 ruby-ng_rspec() {
645 if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
646 ewarn "Missing dev-ruby/rspec in \${DEPEND}"
647 fi
648
649 local rspec_params=
650 case ${NOCOLOR} in
651 1|yes|true)
652 rspec_params+=" --no-color"
653 ;;
654 *)
655 rspec_params+=" --color"
656 ;;
657 esac
658
659 case ${TEST_VERBOSE} in
660 1|yes|true)
661 rspec_params+=" --format documentation"
662 ;;
663 *)
664 rspec_params+=" --format progress"
665 ;;
666 esac
667
668 ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed"
669 }
670
671 # @FUNCTION: ruby-ng_cucumber
672 # @DESCRIPTION:
673 # This is simply a wrapper around the cucumber command (executed by $RUBY})
674 # which also respects TEST_VERBOSE and NOCOLOR environment variables.
675 ruby-ng_cucumber() {
676 if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
677 ewarn "Missing dev-util/cucumber in \${DEPEND}"
678 fi
679
680 local cucumber_params=
681 case ${NOCOLOR} in
682 1|yes|true)
683 cucumber_params+=" --no-color"
684 ;;
685 *)
686 cucumber_params+=" --color"
687 ;;
688 esac
689
690 case ${TEST_VERBOSE} in
691 1|yes|true)
692 cucumber_params+=" --format pretty"
693 ;;
694 *)
695 cucumber_params+=" --format progress"
696 ;;
697 esac
698
699 if [[ ${RUBY} == *jruby ]]; then
700 ewarn "Skipping cucumber tests on JRuby (unsupported)."
701 return 0
702 fi
703
704 ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed"
705 }
706
707 # @FUNCTION: ruby-ng_testrb-2
708 # @DESCRIPTION:
709 # This is simply a replacement for the testrb command that load the test
710 # files and execute them, with test-unit 2.x. This actually requires
711 # either an old test-unit-2 version or 2.5.1-r1 or later, as they remove
712 # their script and we installed a broken wrapper for a while.
713 # This also respects TEST_VERBOSE and NOCOLOR environment variables.
714 ruby-ng_testrb-2() {
715 if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
716 ewarn "Missing dev-ruby/test-unit in \${DEPEND}"
717 fi
718
719 local testrb_params=
720 case ${NOCOLOR} in
721 1|yes|true)
722 testrb_params+=" --no-use-color"
723 ;;
724 *)
725 testrb_params+=" --use-color=auto"
726 ;;
727 esac
728
729 case ${TEST_VERBOSE} in
730 1|yes|true)
731 testrb_params+=" --verbose=verbose"
732 ;;
733 *)
734 testrb_params+=" --verbose=normal"
735 ;;
736 esac
737
738 ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed"
739 }

  ViewVC Help
Powered by ViewVC 1.1.20