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 | 15 ++++++++++++++- |
13 |
1 file changed, 14 insertions(+), 1 deletion(-) |
14 |
|
15 |
diff --git a/eclass/tree-sitter-grammar.eclass |
16 |
b/eclass/tree-sitter-grammar.eclass |
17 |
index acdb8a7ad73..958b2ce21c7 100644 |
18 |
--- a/eclass/tree-sitter-grammar.eclass |
19 |
+++ b/eclass/tree-sitter-grammar.eclass |
20 |
@@ -29,7 +29,10 @@ 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 |
+ |
28 |
+EXPORT_FUNCTIONS src_compile src_test src_install |
29 |
|
30 |
# @ECLASS_VARIABLE: TS_PV |
31 |
# @PRE_INHERIT |
32 |
@@ -89,6 +92,16 @@ tree-sitter-grammar_src_compile() { |
33 |
-o "${WORKDIR}"/${soname} |
34 |
} |
35 |
|
36 |
+# @FUNCTION: tree-sitter-grammar_src_test |
37 |
+# @DESCRIPTION: |
38 |
+# Runs the Tree Sitter parser's test suite. |
39 |
+# See: |
40 |
https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test |
41 |
+tree-sitter-grammar_src_test() { |
42 |
+ debug-print-function ${FUNCNAME} "${@}" |
43 |
+ |
44 |
+ (cd .. && tree-sitter test) || die "Test suite failed" |
45 |
+} |
46 |
+ |
47 |
# @FUNCTION: tree-sitter-grammar_src_install |
48 |
# @DESCRIPTION: |
49 |
# Installs the Tree Sitter parser library. |
50 |
-- |
51 |
2.38.1 |