hackney icon indicating copy to clipboard operation
hackney copied to clipboard

use 'unite' for eunit error formatting

Open binarytemple opened this issue 8 years ago • 11 comments

'unite' provides way nicer error output from 'eunit' tests - one thing I found particularly useful when hacking on hackney was the fact that it provides diff'd output on 'assertEqual' assertions whereas the default output formatter truncates the output.

A follow up P/R will patch the unit tests to use assertions rather than equality checks, e.g:

[{V, ?assertEqual(R,hackney_url:parse_url(V)) } || {V, R} <- Tests] ++

I have an active P/R with eproxus to correct a unhandled case statement - this dependency is to my patched version.

Examples:

1) "module 'hackney_integration_tests'"                              
    get_request/0 (/common/hackney/_build/test/lib/hackney/test/hackney_integration_tests.erl:49)                                            
    Instantiation failed:          
    exception error: no match of right hand side value {error,econnrefused}                                                                        in function  hackney_integration_tests:get_request/0 (/common/hackney/_build/test/lib/hackney/test/hackney_integration_tests.erl, line 49)
      in call from hackney_integration_tests:all_tests/0 (/common/hackney/_build/test/lib/hackney/test/hackney_integration_tests.erl, line 7)      in call from hackney_integration_tests:'-http_requests_test_/0-fun-2-'/1 (/common/hackney/_build/test/lib/hackney/test/hackney_integration_tests.erl, line 38)

151 tests passed  1 fixture cancelled  (0.93 s)                       
===> Error running tests

('assertMatch')

 1) parse_and_unparse_url_test_/0 (/common/hackney/_build/test/lib/hackney/test/hackney_url_tests.erl:140)
    Generator failed!
    exception error: {assertEqual,
                         [{module,hackney_url_tests},
                          {line,140},
                          {expression,"hackney_url : parse_url ( V )"},
                          {expected,
                              {hackney_url,hackney_tcp,foo,<<"www.example.com">>,
                                  <<"/path?key=value#Section%205">>,<<"/path">>,
                                  <<"key=value">>,<<"Section%205">>,
                                  "www.example.com",80,<<>>,<<>>}},
                          {value,
                              {hackney_url,hackney_tcp,http,
                                  <<"www.example.com">>,
                                  <<"/path?key=value#Section%205">>,<<"/path">>,
                                  <<"key=value">>,<<"Section%205">>,
                                  "www.example.com",80,<<>>,<<>>}}]}
      in function  hackney_url_tests:'-parse_and_unparse_url_test_/0-fun-0-'/2 (/common/hackney/_build/test/lib/hackney/test/hackney_url_tests.erl, line 140)
      in call from hackney_url_tests:'-parse_and_unparse_url_test_/0-lc$^1/1-1-'/2 (/common/hackney/_build/test/lib/hackney/test/hackney_url_tests.erl, line 140)

87 tests passed  3 fixtures cancelled  (0.72

binarytemple avatar Jul 17 '17 12:07 binarytemple

I've updated the example in the P/R - please ignore the example given in the original commit message ....

binarytemple avatar Jul 17 '17 12:07 binarytemple

Thanks for the patch. Is unite available on hex? I would prefer to pass a source package name instead

benoitc avatar Jul 30 '17 16:07 benoitc

I don't believe so, and there are P/R outstanding for a year on the project (hence my fork). I'm going to reach out to the author (@eproxus).

binarytemple avatar Jul 31 '17 08:07 binarytemple

Hi everyone, I'm back from vacation now. 😄 I'd be happy to put Unite on hex and upgrade it to Rebar3. For some reason I was not watching my own project, so no notifications... 🤦‍♂️

eproxus avatar Aug 07 '17 11:08 eproxus

Excellent. Thanks Adam. Great library btw.

On Mon, 7 Aug 2017, 12:34 Adam Lindberg, [email protected] wrote:

Hi everyone, I'm back from vacation now. 😄 I'd be happy to put Unite on hex and upgrade it to Rebar3. For some reason I was not watching my own project, so no notifications... 🤦‍♂️

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/benoitc/hackney/pull/421#issuecomment-320640146, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZk5rHtWivHCdHXuMdWvQFXPaqnW0G4ks5sVvYwgaJpZM4OZ7M1 .

binarytemple avatar Aug 07 '17 11:08 binarytemple

Unite is now on Hex.pm: https://hex.pm/packages/unite

There's one caveat and that is that the compatibility fixes for pre-18 versions of Erlang are not in yet. I'll work on those next.

eproxus avatar Sep 13 '17 11:09 eproxus

@eproxus did you manage to have pre-18 support?

benoitc avatar Oct 08 '17 13:10 benoitc

@benoitc Not yet. I'll try to finish it this week.

eproxus avatar Oct 09 '17 08:10 eproxus

@benoitc Unite 0.3.0 is now published with hex with backwards compatibility

eproxus avatar Oct 20 '17 17:10 eproxus

Nice!

On Fri, 20 Oct 2017, 18:14 Adam Lindberg, [email protected] wrote:

@benoitc https://github.com/benoitc Unite 0.3.0 is now published with hex with backwards compatibility

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/benoitc/hackney/pull/421#issuecomment-338267700, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZk5oAvpXEBOEJ56LYeFW977VqMShCBks5suNTugaJpZM4OZ7M1 .

binarytemple avatar Oct 20 '17 17:10 binarytemple

Is this pull request still valid? I find the current eunit output quite readable, and I can't see unite being used.

paulo-ferraz-oliveira avatar Dec 19 '20 01:12 paulo-ferraz-oliveira