commit:     1b48d59f69f5ac0d162437b13601f7b666d3eed2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 27 12:43:13 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 27 13:23:58 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b48d59f

dev-ruby/pcaprub: wire up tests

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-ruby/pcaprub/pcaprub-0.13.1.ebuild | 51 ++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 6 deletions(-)

diff --git a/dev-ruby/pcaprub/pcaprub-0.13.1.ebuild 
b/dev-ruby/pcaprub/pcaprub-0.13.1.ebuild
index a2557b0dd274..b977b4d6165b 100644
--- a/dev-ruby/pcaprub/pcaprub-0.13.1.ebuild
+++ b/dev-ruby/pcaprub/pcaprub-0.13.1.ebuild
@@ -1,14 +1,13 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-USE_RUBY="ruby26 ruby27 ruby30"
+USE_RUBY="ruby27 ruby30"
 
 RUBY_FAKEGEM_EXTRADOC="FAQ.rdoc README.rdoc USAGE.rdoc"
-
 RUBY_FAKEGEM_EXTENSIONS=(ext/pcaprub_c/extconf.rb)
-
+RUBY_FAKEGEM_TASK_TEST="test"
 inherit ruby-fakegem
 
 DESCRIPTION="Libpcap bindings for ruby compat"
@@ -21,5 +20,45 @@ KEYWORDS="~amd64 ~arm ~x86"
 DEPEND+="net-libs/libpcap"
 RDEPEND+="net-libs/libpcap"
 
-# Tests require live access to a network device as root.
-RESTRICT="test"
+ruby_add_bdepend "
+       test? (
+               >=dev-ruby/rake-compiler-0.6.0
+       )
+"
+
+all_ruby_prepare() {
+       sed -i \
+               -e '/\(minitest\|shoulda-context\)/s:~>:>=:' \
+               -e '/coveralls/d' \
+               -e '/rubygems-tasks/d' \
+               -e '/gem.*git/d' \
+               Gemfile || die
+
+       sed -i \
+               -e '/rubygems\/tasks/d' \
+               -e '/Gem::Tasks/d' \
+               -e "/^require 'git'/,/end/ s/^/#/" \
+               Rakefile || die
+
+       sed -i -e '/coveralls/Id' test/test_helper.rb || die
+
+       # Tests which need escalated privileges
+       local privileged_tests=(
+               test_set_datalink
+               test_create_from_primitives
+               test_filter
+               test_pcap_stats
+               test_pcap_datalink
+               test_pcap_inject
+               test_pcap_next
+               test_pcap_setfilter
+               test_pcap_snapshot
+       )
+
+       local privileged_tests_expr=$(printf "%s\|" "${privileged_tests[@]}")
+       privileged_tests_expr="${privileged_tests_expr::-2}"
+
+       sed -i \
+               -e "/def \(${privileged_tests_expr}\)/,/^  end/s/^/#/" \
+               test/test_pcaprub_unit.rb || die
+}

Reply via email to