From fb867366f4760da94f732c296601f7c324de0418 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 21 Jun 2026 23:57:34 -0400 Subject: fix(elisp): exclude generated package files from coverage source scan cj/coverage-summary--source-files scanned SOURCE-DIR for *.el and treated every match as testable source. Build tools write NAME-autoloads.el and NAME-pkg.el into that dir, and undercover never instruments them, so the missing-file detection counted each as untested at 0% and dragged the file-weighted project number down. emacs-wttrin read 72.9% instead of 97.2% after eask wrote its autoloads file during a coverage run. seq-remove the generated files before returning. A genuinely untested source is still flagged. The new test asserts both. --- languages/elisp/tests/test-coverage-summary.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'languages/elisp/tests') diff --git a/languages/elisp/tests/test-coverage-summary.el b/languages/elisp/tests/test-coverage-summary.el index 5be03b3..ed3a6a0 100644 --- a/languages/elisp/tests/test-coverage-summary.el +++ b/languages/elisp/tests/test-coverage-summary.el @@ -135,6 +135,24 @@ is a JSON array string like \"[1, 0, null]\"." (missing (cj/coverage-summary--missing tracked src root))) (should (null missing))))) +(ert-deftest cs-missing-excludes-generated-package-files () + "Generated -autoloads.el / -pkg.el are not source, so a build tool writing +them does not drag the number down; a genuinely untested source is still +flagged (the filter is not over-broad)." + (cs-test--with-project + (list :sources '(("real.el" . ";; r") ("untested.el" . ";; u") + ("proj-autoloads.el" . ";; gen") + ("proj-pkg.el" . ";; gen")) + :report (cs-test--report '(("real.el" . "[1, 1]")))) + (let* ((table (cj/coverage-summary--under-dir + (cj/coverage-summary--parse-file report) src root)) + (tracked (let (ks) (maphash (lambda (k _v) (push k ks)) table) ks)) + (missing (mapcar #'file-name-nondirectory + (cj/coverage-summary--missing tracked src root)))) + (should (member "untested.el" missing)) + (should-not (member "proj-autoloads.el" missing)) + (should-not (member "proj-pkg.el" missing))))) + ;; --- project number (unit-weighted, missing as 0%) ------------------------- (ert-deftest cs-project-pct-unit-weighted-with-missing-as-zero () -- cgit v1.2.3