aboutsummaryrefslogtreecommitdiff
path: root/languages/elisp/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-21 23:57:34 -0400
committerCraig Jennings <c@cjennings.net>2026-06-21 23:57:34 -0400
commitfb867366f4760da94f732c296601f7c324de0418 (patch)
tree317c1b1dafb622c12572b6c907e7104114751dbd /languages/elisp/tests
parented27e3c760bdc924edcba85bc99ed083df484086 (diff)
downloadrulesets-fb867366f4760da94f732c296601f7c324de0418.tar.gz
rulesets-fb867366f4760da94f732c296601f7c324de0418.zip
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.
Diffstat (limited to 'languages/elisp/tests')
-rw-r--r--languages/elisp/tests/test-coverage-summary.el18
1 files changed, 18 insertions, 0 deletions
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 ()