From 3f734920d2713924124b3fe8b0edf0c4b9c82bc8 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 18 Jul 2026 17:45:00 -0500 Subject: fix(prog): cover classic modes and warn for missing dev tools Classic go-mode and js-mode buffers got none of the ts-mode setup, and web-mode got the format key without the promised company/flyspell/LSP. All three now run the shared setup. The web-mode LSP attach guards on the HTML language server, so machines without it stay silent instead of prompting. gopls, clangd, clang-format, bash-language-server, shfmt, and shellcheck now warn at load when missing. The shfmt, shellcheck, and clang-format blocks gate on :if, which evaluates once at startup, so an absent tool silently disabled that setup until the next restart. I also put ~/go/bin on exec-path at load so the gopls check doesn't misreport a gopls installed there. --- tests/test-prog-c--tool-warnings.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test-prog-c--tool-warnings.el (limited to 'tests/test-prog-c--tool-warnings.el') diff --git a/tests/test-prog-c--tool-warnings.el b/tests/test-prog-c--tool-warnings.el new file mode 100644 index 00000000..9d4da57e --- /dev/null +++ b/tests/test-prog-c--tool-warnings.el @@ -0,0 +1,34 @@ +;;; test-prog-c--tool-warnings.el --- Load-time missing-tool warnings -*- lexical-binding: t; -*- + +;;; Commentary: +;; The config audit flagged clangd for the load-time missing-tool +;; warning pyright/prettier already have. clang-format is the same +;; class: its use-package block gates on `:if (executable-find ...)', +;; which evaluates once at startup, so an absent binary silently +;; disables the format key until the next restart — the warn is the +;; only visible trace. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory)) +(require 'testutil-format-wiring) +(format-test--ensure-packages-init) +(require 'prog-c) + +(ert-deftest test-prog-c-warns-when-tools-missing () + "Error: loading without the C tools on PATH warns for each one." + (let ((warned '())) + (cl-letf (((symbol-function 'executable-find) (lambda (&rest _) nil)) + ((symbol-function 'display-warning) + (lambda (_type msg &rest _) (push msg warned)))) + (load (expand-file-name "modules/prog-c.el" user-emacs-directory) nil t)) + (dolist (tool '("clangd" "clang-format")) + (should (cl-some (lambda (m) (string-match-p (regexp-quote tool) m)) + warned))))) + +(provide 'test-prog-c--tool-warnings) +;;; test-prog-c--tool-warnings.el ends here -- cgit v1.2.3