Skip to content

Commit

Permalink
Optionally (not by default) display indirect build output, e.g. Elisp…
Browse files Browse the repository at this point in the history
… byte-compilation.
  • Loading branch information
doublep committed Apr 28, 2024
1 parent 12f086d commit 8803491
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 12 deletions.
2 changes: 1 addition & 1 deletion eldev-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ This function may only be called while inside the body of a
(eldev-build-abort-branch))
(eldev-build-target (car entry))))))
(when (= (hash-table-count eldev--build-results) 0)
(eldev-print "Nothing to do"))
(eldev-print-nothing-to-do))
(maphash (lambda (_target status) (unless (eq status 'built) (setf anything-failed t))) eldev--build-results)
;; See e.g. test `eldev-loading-modes-3'. Basically, once we load the main
;; project's package (in `as-is' mode), it would never get reloaded later, which
Expand Down
2 changes: 1 addition & 1 deletion eldev-doctor.el
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ or “NO”, depending on `ok'."
(eldev-format-message "%d of them" num-visibly-failed))
(if (= num-visibly-failed 1) "a warning" "warnings"))
(signal 'eldev-quit 1)))
(eldev-print "Nothing to delete"))))
(eldev-print-nothing-to-do))))

(defun eldev--doctor-build-sequence (sequence name user-requested &optional dependency-stack)
;; A project may disable certain tests. They still run when non-user-requested
Expand Down
12 changes: 12 additions & 0 deletions eldev-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ Since 1.4.")

(defvar eldev--real-stderr-output nil)

;; Might want to make part of public interface.
(defvar eldev--skip-nothing-to-do-messages nil)


(defalias 'eldev-format-message (if (fboundp 'format-message) 'format-message #'format)
"Like `format-message' if that is defined.
Expand Down Expand Up @@ -1072,6 +1075,15 @@ Since 1.4."
(when (> eldev-debugging-output-level 0)
(make-string (* eldev-debugging-output-level 2) ? )))

(defun eldev-print-nothing-to-do (&optional message)
"Print a “Nothing to do” message.
If MESSAGE is specified, it gets printed instead. However, its
meaning should be similar.
Since 1.10."
(unless eldev--skip-nothing-to-do-messages
(eldev-print "%s" (or message "Nothing to do"))))


(defmacro eldev-with-verbosity-level-except (level functions-with-original-level &rest body)
"Execute BODY with given LEVEL of verbosity.
Expand Down
2 changes: 1 addition & 1 deletion eldev-vc.el
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Try evaluating `(package-buffer-info)' in a buffer with the file")
((= num-possible 1) "replace the existing hook file")
(t "replace existing hook files")))
(when (= num-processed 0)
(eldev-print "Nothing to do")))))
(eldev-print-nothing-to-do)))))

;; FIXME: Rename and move somewhere? Looks generally useful.
(defun eldev--githooks-is-copy (file1 file2)
Expand Down
36 changes: 27 additions & 9 deletions eldev.el
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,21 @@ tools.

Since 0.9.")

(defvar eldev-display-indirect-build-stdout nil
"Whether to display standard output of indirect builds.
For example, if the loading mode is `compiled', such output might
contain “ELC ...” lines. This affects the project itself and all
its local dependencies. Display of directly-ordered builds (e.g.
using commands `build', `compile') is always displayed.

Default value is nil since such output might be confused with
output of the “main” command that triggered the build,
e.g. `test', especially when it is parsed programmatically.
However, if this is not a concern in your case, you may want to
set the variable to t. It is not controllable from command line.

Since 1.10.")


(defvar eldev-force-override nil
"Set to non-nil to disable all command and option duplicate checks.")
Expand Down Expand Up @@ -3251,17 +3266,20 @@ Returns nil if it is neither a project nor a local dependency."
(eldev-verbose "Preparing to load local dependency `%s' in mode `%s'" dependency-name loading-mode))
(let ((default-directory dependency-dir))
(dolist (command commands)
(when eldev-display-indirect-build-stdout
(setf command `("--setup" "(setf eldev--skip-nothing-to-do-messages t)" ,@command)))
(eldev-call-process (eldev-shell-command) command
:forward-output 'stderr
:destination '(t nil)
:forward-output (if eldev-display-indirect-build-stdout t 'stderr)
:destination (if eldev-display-indirect-build-stdout t '(t nil))
:trace-command-line (eldev-format-message "Full command line (in directory `%s')" default-directory)
:die-on-error (if project-itself
"child Eldev process"
(eldev-format-message "child Eldev process for local dependency `%s'" dependency-name))
(if (= (point-min) (point-max))
(eldev-verbose "Child Eldev process produced no output (other than maybe on stderr)")
(eldev-verbose "(Non-stderr) output of the child Eldev process:")
(eldev-verbose (buffer-string)))
(unless eldev-display-indirect-build-stdout
(if (= (point-min) (point-max))
(eldev-verbose "Child Eldev process produced no output (other than maybe on stderr)")
(eldev-verbose "(Non-stderr) output of the child Eldev process:")
(eldev-verbose (buffer-string))))
(when (string= (car command) "package")
(eldev-discard-ansi-control-sequences)
(goto-char (point-max))
Expand Down Expand Up @@ -3467,8 +3485,8 @@ be used on the command line."
(eldev-print "Deleted %s" deleted-dirs))
((> num-deleted-files 0)
(eldev-print "Deleted %s" deleted-files)))))
(when (and (= num-deleted-files 0) (= num-deleted-dirs 0))
(eldev-print "Nothing to delete"))))
(when (= num-deleted-files 0) (= num-deleted-dirs 0)
(eldev-print-nothing-to-do "Nothing to delete"))))

(defun eldev-clean-fileset ()
"Return effective fileset to clean."
Expand Down Expand Up @@ -4970,7 +4988,7 @@ least one warning."
(if (> eldev--lint-num-warnings 0)
(signal 'eldev-error `("Linting produced warnings"))
(eldev-print (if (cdr linters) "Linters have %s" "Linter has %s") (eldev-colorize "no complaints" 'success))))
(eldev-print "Nothing to do"))))
(eldev-print-nothing-to-do))))

(defun eldev-lint-default-p (linter)
(and (pcase eldev-lint-default
Expand Down
16 changes: 16 additions & 0 deletions test/eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,20 @@
(should (= exit-code 1))))


(eldev-ert-defargtest eldev-eval-indirect-build-output (display-output)
(nil t)
(let ((eldev--test-project "trivial-project"))
(eldev--test-run nil ("clean" "all")
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(setf eldev-display-indirect-build-stdout ,display-output)
"--source" "eval" `1)
;; There must be no "Nothing to..." message even when displaying output.
(should (equal (eldev--test-line-list stdout) `("1")))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(setf eldev-display-indirect-build-stdout ,display-output)
"--byte-compiled" "eval" `1)
(should (equal (eldev--test-line-list stdout) `(,@(when display-output '("ELC trivial-project.el")) "1")))
(should (= exit-code 0)))))


(provide 'test/eval)

0 comments on commit 8803491

Please sign in to comment.