Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Cc: ruby@g.o, Sam James <sam@g.o>
Subject: [gentoo-dev] [PATCH v2 3/3] ruby-fakegem.eclass: allow non-fatal use of test functions
Date: Sat, 18 Mar 2023 23:13:51
Message-Id: 20230318231259.3814839-3-sam@gentoo.org
In Reply to: [gentoo-dev] [PATCH v2 1/3] ruby-ng.eclass: allow non-fatal use of test functions by Sam James
1 die -n will make die become non-fatal if run under 'nonfatal',
2 this is useful if e.g. need to do cleanup.
3
4 For example, in an ebuild, I need to setup a database, run tests,
5 then always cleanup, which looks like:
6 ```
7 db_setup
8 nonfatal each_fakegem_test || tests_failed=1
9 db_cleanup
10
11 if [[ ${tests_failed} == 1 ]] ; then
12 die "Tests failed! Please see ..."
13 fi
14 ```
15
16 Just like we do with e.g. virtualx. This also brings us into line
17 with the Python eclasses.
18
19 Signed-off-by: Sam James <sam@g.o>
20 ---
21 eclass/ruby-fakegem.eclass | 4 ++--
22 1 file changed, 2 insertions(+), 2 deletions(-)
23
24 diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
25 index 8cf5dd70f8646..9ef5e1f098d11 100644
26 --- a/eclass/ruby-fakegem.eclass
27 +++ b/eclass/ruby-fakegem.eclass
28 @@ -1,4 +1,4 @@
29 -# Copyright 1999-2022 Gentoo Authors
30 +# Copyright 1999-2023 Gentoo Authors
31 # Distributed under the terms of the GNU General Public License v2
32
33 # @ECLASS: ruby-fakegem.eclass
34 @@ -552,7 +552,7 @@ each_fakegem_test() {
35
36 case ${RUBY_FAKEGEM_RECIPE_TEST} in
37 rake)
38 - MT_NO_PLUGINS=true ${RUBY} --disable=did_you_mean -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
39 + MT_NO_PLUGINS=true ${RUBY} --disable=did_you_mean -S rake ${RUBY_FAKEGEM_TASK_TEST} || die -n "tests failed"
40 ;;
41 rspec)
42 RSPEC_VERSION=2 ruby-ng_rspec
43 --
44 2.40.0