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

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.54 - (show annotations) (download)
Thu Jan 16 07:57:40 2014 UTC (11 months ago) by graaff
Branch: MAIN
CVS Tags: HEAD
Changes since 1.53: +3 -3 lines
Explicitly cp symlinks as-is. The default for this changed in coreutils 8.22. Fixes bug 472710.

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

  ViewVC Help
Powered by ViewVC 1.1.20