summaryrefslogtreecommitdiff
blob: 7e785cccf7eed3de01ae4ae5511f4260632bf8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
USE_RUBY="ruby31 ruby32 ruby33"

RUBY_FAKEGEM_TASK_TEST="test:unit"
RUBY_FAKEGEM_EXTRADOC="README.md"

MY_PN=${PN/-/_}
RUBY_FAKEGEM_EXTENSIONS=(ext/${MY_PN}/extconf.rb)

inherit ruby-fakegem

DESCRIPTION="Liquid performance extension in C"
HOMEPAGE="https://github.com/Shopify/liquid-c"

LICENSE="MIT"
SLOT="$(ver_cut 1)"
KEYWORDS="~amd64 ~arm64"

ruby_add_rdepend ">=dev-ruby/liquid-5.0.1:*"

all_ruby_prepare() {
	sed -i -e "s/-Werror//" ext/${MY_PN}/extconf.rb || die

	sed -i \
		-e "/[Bb]undler/d" \
		-e "/memcheck/Id" \
		-e '/extensiontask/ s:^:#:' \
		Rakefile || die
	sed -i -e 's/unit: :compile/:unit/' rakelib/unit_test.rake || die
	rm -r rakelib/compile.rake || die

	sed -i -e 's/MiniTest/Minitest/' test/unit/*_test.rb || die

	# ruby_memcheck is a gem just for running w/ valgrind.
	# We don't run tests in ebuilds with Valgrind because it's
	# non-portable and sometimes flaky under sandbox.
	rm rakelib/integration_test.rake || die
	sed -i -e '/memcheck/Id' rakelib/unit_test.rake || die
}

each_ruby_test() {
	# Backup the original extension and hide it away
	# The tests won't build if they detect an already-built ext
	mkdir -p "${T}"/${RUBY}.orig || die
	mv ext "${T}"/${RUBY}.orig/ext || die
	cp -r "${WORKDIR}"/all/${P}/ext ext || die

	nonfatal each_fakegem_test --trace || failed_tests=1

	# Always restore the original extension we built, even if
	# tests failed, as FEATURES=test-fail-continue may be enabled.
	rm -rf ext || die
	mv "${T}"/${RUBY}.orig/ext ext || die

	if [[ ${failed_tests} == 1 ]] ; then
		die "Tests failed with ${RUBY}!"
	fi
}