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

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.58 - (show annotations) (download)
Mon Jun 29 11:01:31 2015 UTC (4 weeks, 3 days ago) by mrueg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.57: +4 -4 lines
Quote RUBY_S and sub_S as the directory could contain spaces.

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

  ViewVC Help
Powered by ViewVC 1.1.20