diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-21 23:59:29 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-21 23:59:29 -0400 |
| commit | 0751b3c0f4e56061e79aa408493f77510e08f053 (patch) | |
| tree | 43dbdd79c63bf52e1559ee87cc0680731fbf4c16 /languages/elisp/tests | |
| parent | fb867366f4760da94f732c296601f7c324de0418 (diff) | |
| download | rulesets-0751b3c0f4e56061e79aa408493f77510e08f053.tar.gz rulesets-0751b3c0f4e56061e79aa408493f77510e08f053.zip | |
test(elisp): cover coverage-summary source-file scan and under-dir filtering
Adds direct tests for cj/coverage-summary--source-files (non-recursive, subdirectories out of scope) and --under-dir (report entries outside the source dir dropped, survivors re-keyed relative to project root). Both were previously exercised only indirectly through the missing-file tests.
Diffstat (limited to 'languages/elisp/tests')
| -rw-r--r-- | languages/elisp/tests/test-coverage-summary.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/languages/elisp/tests/test-coverage-summary.el b/languages/elisp/tests/test-coverage-summary.el index ed3a6a0..a4525db 100644 --- a/languages/elisp/tests/test-coverage-summary.el +++ b/languages/elisp/tests/test-coverage-summary.el @@ -109,6 +109,33 @@ is a JSON array string like \"[1, 0, null]\"." (ert-deftest cs-file-pct-fully-covered () (should (= 100.0 (cj/coverage-summary--file-pct 4 4)))) +;; --- source-file scan and under-dir filtering ------------------------------ + +(ert-deftest cs-source-files-is-non-recursive () + "Only top-level *.el under SOURCE-DIR are source; files in subdirectories +are out of scope." + (cs-test--with-project + (list :sources '(("top.el" . ";; t") ("sub/nested.el" . ";; n")) + :report (cs-test--report '(("top.el" . "[1]")))) + (let ((sources (mapcar #'file-name-nondirectory + (cj/coverage-summary--source-files src root)))) + (should (member "top.el" sources)) + (should-not (member "nested.el" sources))))) + +(ert-deftest cs-under-dir-filters-outside-source-and-rekeys () + "Report entries outside SOURCE-DIR are dropped; survivors are keyed +relative to PROJECT-ROOT." + (cs-test--with-project + (list :sources '(("in.el" . ";; i")) + :report (cs-test--report '(("in.el" . "[1, 1]") + ("../out.el" . "[1, 0]")))) + (let* ((table (cj/coverage-summary--under-dir + (cj/coverage-summary--parse-file report) src root)) + (keys (let (ks) (maphash (lambda (k _v) (push k ks)) table) ks))) + (should (equal keys (list (file-relative-name + (expand-file-name "src/in.el" root) root)))) + (should (= 1 (hash-table-count table)))))) + ;; --- missing-file detection (the kernel) ----------------------------------- (ert-deftest cs-missing-finds-ondisk-file-absent-from-report () |
