* [gentoo-dev] [PATCH 2/3] tree-sitter-grammar.eclass: Add src_test implementation
@ 2022-12-03 18:30 matoro
0 siblings, 0 replies; only message in thread
From: matoro @ 2022-12-03 18:30 UTC (permalink / raw
To: Gentoo Dev
These packages have a standard way of implementing a test corpus that
can be invoked by "tree-sitter test" from dev-util/tree-sitter-cli.
Some have additional platform-specific tests that are invoked in a
custom manner, but these are on top of the basic test corpus.
See:
https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test
Bug: https://bugs.gentoo.org/844223
Closes: https://github.com/gentoo/gentoo/pull/28529
Signed-off-by: Matoro Mahri <matoro@users.noreply.github.com>
---
eclass/tree-sitter-grammar.eclass | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/eclass/tree-sitter-grammar.eclass
b/eclass/tree-sitter-grammar.eclass
index acdb8a7ad73..958b2ce21c7 100644
--- a/eclass/tree-sitter-grammar.eclass
+++ b/eclass/tree-sitter-grammar.eclass
@@ -29,7 +29,10 @@ S="${WORKDIR}"/${PN}-${TS_PV:-${PV}}/src
# Needed for tree_sitter/parser.h
DEPEND="dev-libs/tree-sitter"
-EXPORT_FUNCTIONS src_compile src_install
+BDEPEND+=" test? ( dev-util/tree-sitter-cli )"
+IUSE+=" test"
+
+EXPORT_FUNCTIONS src_compile src_test src_install
# @ECLASS_VARIABLE: TS_PV
# @PRE_INHERIT
@@ -89,6 +92,16 @@ tree-sitter-grammar_src_compile() {
-o "${WORKDIR}"/${soname}
}
+# @FUNCTION: tree-sitter-grammar_src_test
+# @DESCRIPTION:
+# Runs the Tree Sitter parser's test suite.
+# See:
https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test
+tree-sitter-grammar_src_test() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (cd .. && tree-sitter test) || die "Test suite failed"
+}
+
# @FUNCTION: tree-sitter-grammar_src_install
# @DESCRIPTION:
# Installs the Tree Sitter parser library.
--
2.38.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-03 18:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-03 18:30 [gentoo-dev] [PATCH 2/3] tree-sitter-grammar.eclass: Add src_test implementation matoro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox