How to make Emacs compilation warning errors

In my ongoing integration testing for my emacs fsharp-mode package, I add byte compilation to the tests to have immediate feedback. I roughly use:

emasc -batch batch-byte-compile *.el 

This returns a nonzero value if there is an error, but not if it is just a warning. I would also like to get a warning if there are any warnings, as this may include calls to undefined functions (which happened earlier than the caveat).

So: how can I get a non-zero return code in case of compilation warnings?

+5
source share
1 answer

You can set byte-compile-error-on-warn value other than zero, as in:

 $ emacs -Q --batch \ --eval '(setq byte-compile-error-on-warn t)' \ -f batch-byte-compile *.el 

Now the byte compiler stops at the first warning, so you should make this parameter optional in your Makefile and use it only in CI settings.

If you need more sophisticated control than this, you should write your own post-processor, for example. A Python script that analyzes the output from the byte compiler and adjusts the exit code and / or output accordingly, or writes its own version of batch-byte-compile , which performs more complex processing.

+5
source

Source: https://habr.com/ru/post/1202074/


All Articles