From 4ea52a61560b6fa25b3d04f484c1ab140c723133 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 1 Jul 2026 22:14:07 -0400 Subject: fix(treesit): prompt before grammar installs, add explicit bootstrap treesit-auto-install was t, so opening a file could silently trigger a network download and compiler build mid-edit. It now prompts, and cj/install-treesit-grammars is the deliberate fresh-machine bootstrap that installs everything in one command. --- .../test-prog-general--install-treesit-grammars.el | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test-prog-general--install-treesit-grammars.el (limited to 'tests') diff --git a/tests/test-prog-general--install-treesit-grammars.el b/tests/test-prog-general--install-treesit-grammars.el new file mode 100644 index 00000000..62bf3920 --- /dev/null +++ b/tests/test-prog-general--install-treesit-grammars.el @@ -0,0 +1,34 @@ +;;; test-prog-general--install-treesit-grammars.el --- Grammar bootstrap command -*- lexical-binding: t; -*- + +;;; Commentary: +;; `treesit-auto-install' is set to `prompt' so opening a file never silently +;; downloads and builds a grammar. `cj/install-treesit-grammars' is the +;; explicit fresh-machine bootstrap: it loads treesit-auto and installs every +;; grammar in one deliberate command. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'prog-general) + +;; Satisfy the command's (require 'treesit-auto) without the real package, +;; which isn't available in batch runs. +(provide 'treesit-auto) + +(ert-deftest test-prog-general-install-treesit-grammars-is-a-command () + "Normal: the bootstrap entry point exists and is interactive." + (should (commandp 'cj/install-treesit-grammars))) + +(ert-deftest test-prog-general-install-treesit-grammars-installs-all () + "Normal: the command delegates to treesit-auto-install-all." + (let ((called 0)) + (cl-letf (((symbol-function 'treesit-auto-install-all) + (lambda (&rest _) (setq called (1+ called))))) + (cj/install-treesit-grammars) + (should (= called 1))))) + +(provide 'test-prog-general--install-treesit-grammars) +;;; test-prog-general--install-treesit-grammars.el ends here -- cgit v1.2.3