From: matoro <matoro_mailinglist_gentoo-dev@matoro.tk>
To: Gentoo Dev <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] [PATCH 2/3] tree-sitter-grammar.eclass: Add src_test implementation
Date: Sat, 03 Dec 2022 13:30:34 -0500 [thread overview]
Message-ID: <4eb68bd0bea06e89dba8474f9c69eef2@matoro.tk> (raw)
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
reply other threads:[~2022-12-03 18:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4eb68bd0bea06e89dba8474f9c69eef2@matoro.tk \
--to=matoro_mailinglist_gentoo-dev@matoro.tk \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox