Skip to content

Commit

Permalink
Add some verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Jan 25, 2021
1 parent a59a28d commit 66e86bc
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions undercover.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Configured using the :merge-report configuration option.")
;; 2 - warnings
;; 4 - potentially useful output which differs across Undercover runs
;; 5 - default
;; 6 - verbose messages which in some situations may point towards a problem
;; 7 - verbose informational messages
(defvar undercover--verbosity 5
"Controls the amount of messages produced.
Expand Down Expand Up @@ -174,6 +175,7 @@ Otherwise, return nil."

(defun undercover--load-file-handler (file)
"Handle the `load' FILE operation."
(undercover--message 7 "Instrumenting %s for collecting coverage information." file)
(let ((edebug-all-defs (undercover--coverage-enabled-p))
(load-file-name (file-truename file))
(load-in-progress t))
Expand Down Expand Up @@ -636,6 +638,8 @@ These values may be overridden through the environment (see
"Calculate and return a hash table representing Undercover's environment."
(let ((env (make-hash-table :test 'eq)))
(undercover--detect-ci env)
(undercover--message 7 "Detected CI: %s"
(or (gethash :ci-name env) "None"))
(undercover--read-env env)
env))

Expand Down Expand Up @@ -858,14 +862,19 @@ These values may be overridden through the environment (see

(defun undercover-coveralls--merge-reports (report)
"Merge test coverage REPORT with existing from `undercover--report-file-path'."
(ignore-errors
(let* ((json-object-type 'hash-table)
(json-array-type 'list)
(old-report (json-read-file undercover--report-file-path))
(new-source-files-report (gethash "source_files" report)))
(dolist (old-file-hash (gethash "source_files" old-report))
(undercover-coveralls--merge-report-file-coverage
old-file-hash new-source-files-report)))))
(condition-case merge-error
(let* ((json-object-type 'hash-table)
(json-array-type 'list)
(old-report (json-read-file undercover--report-file-path))
(new-source-files-report (gethash "source_files" report)))
(undercover--message 7
"Merging existing Coveralls report: %s" undercover--report-file-path)
(dolist (old-file-hash (gethash "source_files" old-report))
(undercover-coveralls--merge-report-file-coverage
old-file-hash new-source-files-report)))
(error
(undercover--message 6
"Failed to merge Coveralls report: %s" merge-error))))

(defun undercover-coveralls--create-report ()
"Create test coverage report for coveralls.io."
Expand Down Expand Up @@ -969,6 +978,8 @@ script (https://codecov.io/bash) instead"))))
(defun undercover-simplecov--merge-reports (new-report)
"Merge test coverage NEW-REPORT with existing from `undercover--report-file-path'."
(when (file-readable-p undercover--report-file-path)
(undercover--message 7
"Merging existing SimpleCov report: %s" undercover--report-file-path)
(let* ((json-object-type 'hash-table)
(json-array-type 'list)
(old-report (json-read-file undercover--report-file-path))
Expand Down Expand Up @@ -1048,7 +1059,7 @@ script (https://codecov.io/bash) instead"))))

(defun undercover--report ()
"Generate and save/upload a test coverage report, as configured."

(undercover--message 7 "Generating report.")
(cl-case undercover--report-format
((nil) (error "UNDERCOVER: Report format not configured and auto-detection failed"))
(coveralls (undercover-coveralls--report))
Expand Down

0 comments on commit 66e86bc

Please sign in to comment.