Reputation: 553
In my continuous integration testing for my emacs package fsharp-mode, I am adding byte-compilation to the tests, in order to have immediate feedback. I am roughly using:
emasc -batch batch-byte-compile *.el
This returns non-zero if there is an error, but not if it is just a warning. I would like to be alerted also if there are any warnings, as this may include calls to undefined functions (which has happened before thanks to a typo).
So: how can I obtain a non-zero return code in case of compilation warnings?
Upvotes: 5
Views: 536
Reputation:
You can set byte-compile-error-on-warn
to a non-nil value, as in:
$ emacs -Q --batch \
--eval '(setq byte-compile-error-on-warn t)' \
-f batch-byte-compile *.el
The byte compiler now stops at the first warning, though, so you should make this setting optional in your Makefile
, and only use it in your CI setup.
If you need more sophisticated control than that, you have to write your own post-processor, e.g. a Python script that parses the output of the byte compiler and adjusts the exit code and/or output accordingly, or write your own batch-byte-compile
variant that does more sophisticated processing.
Upvotes: 5