[Pkg-erlang-devel] [check-all-the-things] 02/02: Fix erl-tidy command line

Sergei Golovan sgolovan at debian.org
Mon May 1 07:42:40 UTC 2017


Hi Paul,

On Mon, May 1, 2017 at 1:40 AM, Paul Wise <pabs at debian.org> wrote:
> On Sun, 2017-04-30 at 15:43 +0200, Jakub Wilk wrote:
>
>> > +command = erl -noshell -eval 'erl_tidy:dir(".", [{{test, true}}, {{verbose, false}}]).' -s init stop
>>
>> While this does work for syntactically correct Erlang files, when I run it
>> against an empty file, it prints an error message, and then hangs forever.
>> Unfortunately, my Erlang fu is too weak to debug this. :/
>
> Erlang folks: any idea how to avoid the hang when using erl_tidy
> against directories containing empty files?

Looks like a bug in erl_tidy:file/2. It spawns a new Erlang process
for tidying a file, but doesn't react if the child exits with error. I
don't know if it's helpful but the attached patch seems to fix this
bug (haven't reported it upstream yet).

Unfortunately, I don't see an easy way around this bug. Either remove
empty files before running erl_tidy, or write an alternative to
erl_tidy:dir which would execute erl_tidy:file, but only for non-empty
files.

As a side note, the correct syntax for option is  [{test, true},
{verbose, false}] (note one level of braces, not two).

Cheers!
-- 
Sergei Golovan
-------------- next part --------------
--- a/lib/syntax_tools/src/erl_tidy.erl
+++ b/lib/syntax_tools/src/erl_tidy.erl
@@ -296,6 +296,8 @@
         {Child, ok} ->
             ok;
         {Child, {error, Reason}} ->
+            exit(Reason);
+        {'EXIT', Child, Reason} ->
             exit(Reason)
     end.
 


More information about the Pkg-erlang-devel mailing list