[erlang-questions] code:clash/0 borking when running eunit tests with rebar

Tuncer Ayaz tuncer.ayaz@REDACTED
Fri Apr 16 19:33:11 CEST 2010


On Fri, Apr 16, 2010 at 4:46 PM, Tuncer Ayaz <tuncer.ayaz@REDACTED> wrote:
> On Fri, Apr 16, 2010 at 3:42 PM, Vlad Dumitrescu <vladdu55@REDACTED> wrote:
>> On Fri, Apr 16, 2010 at 15:31, Jeremy Raymond <jeraymond@REDACTED> wrote:
>>> I can reproduce this without couchbeam as well by just calling
>>> code:clash() directly in my eunit test:
>>>
>>> *** context setup failed ***
>>> ::error:function_clause
>>>  in function code:filter/3
>>>    called as filter(".beam",".eunit",error)
>>>  in call from code:build/1
>>>  in call from code:clash/0
>>>  in call from cdb_data_tests:setup/0
>>
>> Hi,
>>
>> in code.erl:
>>
>> build([]) -> [];
>> build([Dir|Tail]) ->
>>    Files = filter(objfile_extension(), Dir,
>>                   erl_prim_loader:list_dir(Dir)),
>>    [decorate(Files, Dir) | build(Tail)].
>>
>> filter(_Ext, Dir, {error,_}) ->
>>    io:format("** Bad path can't read ~s~n", [Dir]), [];
>> filter(Ext, _, {ok,Files}) ->
>>    filter2(Ext, length(Ext), Files).
>>
>> and in erl_prim_loader.erl
>>
>> -spec list_dir(string()) -> {'ok', [string()]} | 'error'.
>> list_dir(Dir) ->
>>    check_file_result(list_dir, Dir, request({list_dir,Dir})).
>>
>> Where you can see that erl_prim_loader returns 'error' and filter
>> expects {ok, _} or {error, _}. It feels like Dialyzer should have
>> caught that?
>
> Thanks, nice catch!
>
> I've introduced that in 49da83 while fixing another
> code:clash/0 issue.
> Working on a patch with extended tests atop 79194d.

Fix posted to erlang-patches@REDACTED

I think this hasn't been caught earlier as usually invalid
paths are caught in add_path(). A possible failure case is when
a file/directory which is part of the code path disappears.

I've extended the tests to catch that.


More information about the erlang-questions mailing list