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

Vlad Dumitrescu vladdu55@REDACTED
Fri Apr 16 15:42:35 CEST 2010


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?

best regards,
Vlad


More information about the erlang-questions mailing list