From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#69405: [PATCH] .emacs.d/tree-sitter/ not used in tree-sitter tests Date: Mon, 26 Feb 2024 14:36:39 +0100 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_1FCC3A2B-F259-4910-9CD6-886B5FABAB79" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39101"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu To: 69405@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 26 14:38:02 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rebBC-000A2j-6e for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Feb 2024 14:38:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rebAr-00066R-3t; Mon, 26 Feb 2024 08:37:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rebAn-000661-Rv for bug-gnu-emacs@gnu.org; Mon, 26 Feb 2024 08:37:39 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rebAn-0004a8-K8 for bug-gnu-emacs@gnu.org; Mon, 26 Feb 2024 08:37:37 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rebBC-00050u-Ou for bug-gnu-emacs@gnu.org; Mon, 26 Feb 2024 08:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Feb 2024 13:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69405 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.170895464119143 (code B ref -1); Mon, 26 Feb 2024 13:38:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Feb 2024 13:37:21 +0000 Original-Received: from localhost ([127.0.0.1]:36498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rebAX-0004yh-0o for submit@debbugs.gnu.org; Mon, 26 Feb 2024 08:37:21 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rebAV-0004yN-8Q for submit@debbugs.gnu.org; Mon, 26 Feb 2024 08:37:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rebA1-0005Zj-6T for bug-gnu-emacs@gnu.org; Mon, 26 Feb 2024 08:36:49 -0500 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reb9x-0004SL-HO for bug-gnu-emacs@gnu.org; Mon, 26 Feb 2024 08:36:48 -0500 Original-Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-512fd840142so1124074e87.2 for ; Mon, 26 Feb 2024 05:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708954600; x=1709559400; darn=gnu.org; h=to:cc:date:message-id:subject:mime-version:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=VbFuWkJLJIsiNXf+2bGCED0u3OzJhzbkeegH0aB1GEU=; b=GYcbXtLgyTzN4cIMjD26MVIMoeNK9Sot6ouCUCnUOoRueCD99bSh2jo/9VxvKyNNNs Rpk1yVwvwGebSh5JLvPzMPDPDJjcHpXbMnPIPUD4s01d4EWhUQ/xROPRlslivpyLpBu+ sdAH5w2TywpG4Flailpo3RffW50ExmVimSyZUvvOfCxSjFfzYC7/Ep6pBa30J0X2Xrnl PhknS54UWpk3Sk9IzFqtPaCWfF4IZaQNq7TVRG16FU0UZ2p8/P/pOXa05WZZ31/Gs7xd vY9nrgBkCVGNY+uXv1WjVsgmsKK2cnx6/1gaoxWITf7VfCbuiSGCAo+FTZdWh1NOdaRM pNsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708954600; x=1709559400; h=to:cc:date:message-id:subject:mime-version:from:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VbFuWkJLJIsiNXf+2bGCED0u3OzJhzbkeegH0aB1GEU=; b=l5tlH2shedDZVHM0AbTKU4uuW/MidbB49THycCHW4KR50j6tXPa6QRzm/a6IW14ASE ml1NxTkXiR8Nxf+Ex2zC09hLShE4wtSqMWYRgUCVWhMW75U6sL9WZm5v8cY6/rCaMW0i esVF9hoEBFK5+Dlzdx5elJe4m4QkgVpA+Zts2KwT+z1GiZnOA8sDA2DSzyUbYS3LilyO Rwxa7R47aiOKpLs97xDZFVD+2J9veopcVqbbmAvZyDYAw/pkT6D5edwRye/0SqooRE5s 3XVmtY7VOWuJlMd33in+r/Wb5cPLGmojZxFVJpTDWghJZPYuQm8g9lKR02SwIJKfxoys VHMA== X-Gm-Message-State: AOJu0YyOXKmPJ437nKDN8ZjA2riU639fXt79XsL0VHfATdyKFkf7fbk3 hDQZ9NzkoVBXq0geqy5SNtuqhzfGmbUmYUZfqKoHZNn1zgU60TnbognkmYNo X-Google-Smtp-Source: AGHT+IHbIlZP76Nj9aE59ztrtnNIc3fgIDiXzDIUOuswnTzCwYpCTnWliqikMgZa9z4l/chyFIqibQ== X-Received: by 2002:a05:6512:318e:b0:512:fe1f:d3c1 with SMTP id i14-20020a056512318e00b00512fe1fd3c1mr1897376lfe.58.1708954600291; Mon, 26 Feb 2024 05:36:40 -0800 (PST) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id d20-20020ac25454000000b0051300b6a1casm175158lfn.84.2024.02.26.05.36.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2024 05:36:39 -0800 (PST) X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280663 Archived-At: --Apple-Mail=_1FCC3A2B-F259-4910-9CD6-886B5FABAB79 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii The .emacs.d/tree-sitter/ directory isn't searched when running tests = non-interactively. The Makefile sets HOME to /nonexistent, which is = correct but has the unfortunate side-effect of not running all the tests = properly even with the compiled grammars installed. The attached patch adds an environment variable, EMACS_TREE_SITTER_DIR, = and sets it in the Makefile. I didn't bother documenting it because it's = only intended for use in our own tests. --Apple-Mail=_1FCC3A2B-F259-4910-9CD6-886B5FABAB79 Content-Disposition: attachment; filename=test-treesit-dir.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="test-treesit-dir.diff" Content-Transfer-Encoding: 7bit diff --git a/src/treesit.c b/src/treesit.c index d86ab501187..a2eeb89c93d 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -605,6 +605,17 @@ treesit_load_language (Lisp_Object language_symbol, = Fexpand_file_name (concat2 (build_string ("tree-sitter/"), lib_base_name), Fsymbol_value (Quser_emacs_directory)); treesit_load_language_push_for_each_suffix (lib_name, &path_candidates); + + /* Then push the directory of EMACS_TREE_SITTER_DIR, if any. + It is mainly intended for testing purposes, where HOME isn't available. */ + const char *envdir = getenv ("EMACS_TREE_SITTER_DIR"); + if (envdir && *envdir) + { + Lisp_Object lib_name = Fexpand_file_name (lib_base_name, + build_string (envdir)); + treesit_load_language_push_for_each_suffix (lib_name, &path_candidates); + } + /* Then push paths from treesit-extra-load-path. */ Lisp_Object tail; diff --git a/test/Makefile.in b/test/Makefile.in index 720f5c7ff8c..5e7f1ac444b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -118,6 +118,9 @@ emacs = # startup.el must be updated too. TEST_HOME = /nonexistent +# Allow tests using tree-sitter to access grammars installed locally. +TESTENV = HOME=$(TEST_HOME) EMACS_TREE_SITTER_DIR=$(HOME)/.emacs.d/tree-sitter + test_module_dir := src/emacs-module-resources .PHONY: all check @@ -178,7 +181,7 @@ testloadfile = %.log: %.elc $(AM_V_GEN)${MKDIR_P} $(dir $@) - $(AM_V_at)HOME=$(TEST_HOME) $(emacs) \ + $(AM_V_at)$(TESTENV) $(emacs) \ -l ert ${ert_opts} -l $(testloadfile) \ $(TEST_RUN_ERT) @@ -335,7 +338,7 @@ .PHONY: ## summarizing step from running when there is an error. check-doit: ifeq ($(TEST_INTERACTIVE), yes) - HOME=$(TEST_HOME) $(emacs) \ + $(TESTENV) $(emacs) \ -l ert ${ert_opts} \ $(patsubst %,-l %,$(if $(findstring $(TEST_LOAD_EL),yes),$ELFILES,$(ELFILES:.el=))) \ $(TEST_RUN_ERT) --Apple-Mail=_1FCC3A2B-F259-4910-9CD6-886B5FABAB79--