Gentoo Archives: gentoo-dev

From: matoro <matoro_mailinglist_gentoo-dev@××××××.tk>
To: Gentoo Dev <gentoo-dev@l.g.o>
Subject: [gentoo-dev] [PATCH 2/3 v2] tree-sitter-grammar.eclass: Add src_test implementation
Date: Sat, 03 Dec 2022 19:56:25
Message-Id: bbef2484e90009333a01430e4e62a655@matoro.tk
1 These packages have a standard way of implementing a test corpus that
2 can be invoked by "tree-sitter test" from dev-util/tree-sitter-cli.
3 Some have additional platform-specific tests that are invoked in a
4 custom manner, but these are on top of the basic test corpus.
5
6 See:
7 https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test
8 Bug: https://bugs.gentoo.org/844223
9 Closes: https://github.com/gentoo/gentoo/pull/28529
10 Signed-off-by: Matoro Mahri <matoro@××××××××××××××××××××.com>
11 ---
12 eclass/tree-sitter-grammar.eclass | 16 +++++++++++++++-
13 1 file changed, 15 insertions(+), 1 deletion(-)
14
15 diff --git a/eclass/tree-sitter-grammar.eclass
16 b/eclass/tree-sitter-grammar.eclass
17 index acdb8a7ad73..c607ea9ddfb 100644
18 --- a/eclass/tree-sitter-grammar.eclass
19 +++ b/eclass/tree-sitter-grammar.eclass
20 @@ -29,7 +29,11 @@ S="${WORKDIR}"/${PN}-${TS_PV:-${PV}}/src
21 # Needed for tree_sitter/parser.h
22 DEPEND="dev-libs/tree-sitter"
23
24 -EXPORT_FUNCTIONS src_compile src_install
25 +BDEPEND+=" test? ( dev-util/tree-sitter-cli )"
26 +IUSE+=" test"
27 +RESTRICT+=" !test? ( test )"
28 +
29 +EXPORT_FUNCTIONS src_compile src_test src_install
30
31 # @ECLASS_VARIABLE: TS_PV
32 # @PRE_INHERIT
33 @@ -89,6 +93,16 @@ tree-sitter-grammar_src_compile() {
34 -o "${WORKDIR}"/${soname}
35 }
36
37 +# @FUNCTION: tree-sitter-grammar_src_test
38 +# @DESCRIPTION:
39 +# Runs the Tree Sitter parser's test suite.
40 +# See:
41 https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test
42 +tree-sitter-grammar_src_test() {
43 + debug-print-function ${FUNCNAME} "${@}"
44 +
45 + (cd .. && tree-sitter test) || die "Test suite failed"
46 +}
47 +
48 # @FUNCTION: tree-sitter-grammar_src_install
49 # @DESCRIPTION:
50 # Installs the Tree Sitter parser library.
51 --
52 2.38.1