Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make Eunit optional #22

Closed
wants to merge 2 commits into from

4 participants

@rnewson

This makes eunit completely optional, useful for supporting downstream builders like CouchDB.

@etrepum
Owner

I don't understand the purpose of this. How is this useful for downstream builders? eunit ships with OTP.

@rnewson

The Ubuntu/Debian packagers have separated eunit into its own package (erlang-eunit).

Basically, this introduces a new build dependency for couchdb, the original thread discussing the issue is here: http://mail-archives.apache.org/mod_mbox/couchdb-dev/201011.mbox/%3CAANLkTinHaicoN2Qub00mA8q=JnJJB3S1Z-CCPYzuPpDW@mail.gmail.com%3E

@etrepum
Owner

That's a stupid thing for them to do, but OK. I guess I will consider supporting bastardized Debian OTP.

@lemenkov
Collaborator

Disregard of Debian packaging I personally second that change. Mochiweb should include eunit headers only in case of running unit-tests.

@lemenkov
Collaborator

Just for the record - I've got two failed tests with this patch applied to the current head. So this change needs another round before merging.

@rnewson

I see two tests failing here also. Curiously, the tests pass if foo_table is moved above the -ifdef clause. I thought the change I've made in run_tests.escript was recompiling everything with -DTEST but I can only explain this test failure if that's not the case (but then I can't explain why all the others run).

New patch once I figure it out.

@dreid
Collaborator

Commit 550cbed appears to be unnecessary when using rebar to run the tests. I suggest merging master back into your eunit branch and trying that.

@etrepum
Owner

Yes please, if you can rebase this on top of the current master, removing all of the makefile stuff we don't need anymore, then we could get this in soon.

@etrepum
Owner

I recreated a new but equivalent branch from scratch and pushed to master.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2010
  1. make eunit completely optional.

    Robert Newson authored
Commits on Nov 11, 2010
  1. fix mochiweb_cover.erl test in an ugly way.

    Robert Newson authored
This page is out of date. Refresh to see the latest.
Showing with 35 additions and 35 deletions.
  1. +1 −1  src/mochifmt.erl
  2. +1 −1  src/mochifmt_records.erl
  3. +1 −1  src/mochifmt_std.erl
  4. +1 −1  src/mochiglobal.erl
  5. +1 −1  src/mochihex.erl
  6. +1 −1  src/mochijson.erl
  7. +1 −2  src/mochijson2.erl
  8. +1 −1  src/mochilists.erl
  9. +1 −1  src/mochilogfile2.erl
  10. +1 −1  src/mochinum.erl
  11. +1 −1  src/mochitemp.erl
  12. +1 −1  src/mochiutf8.erl
  13. +1 −1  src/mochiweb.erl
  14. +1 −1  src/mochiweb_acceptor.erl
  15. +1 −1  src/mochiweb_app.erl
  16. +1 −1  src/mochiweb_charref.erl
  17. +1 −1  src/mochiweb_cookies.erl
  18. +2 −2 src/mochiweb_cover.erl
  19. +1 −1  src/mochiweb_echo.erl
  20. +1 −1  src/mochiweb_headers.erl
  21. +1 −1  src/mochiweb_html.erl
  22. +1 −1  src/mochiweb_http.erl
  23. +1 −1  src/mochiweb_io.erl
  24. +1 −1  src/mochiweb_mime.erl
  25. +1 −1  src/mochiweb_multipart.erl
  26. +1 −1  src/mochiweb_request.erl
  27. +1 −1  src/mochiweb_response.erl
  28. +1 −1  src/mochiweb_skel.erl
  29. +1 −1  src/mochiweb_socket_server.erl
  30. +1 −1  src/mochiweb_sup.erl
  31. +1 −1  src/mochiweb_util.erl
  32. +1 −1  src/reloader.erl
  33. +2 −1  support/run_tests.escript
View
2  src/mochifmt.erl
@@ -369,8 +369,8 @@ parse_std_conversion([Type], Acc) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
tokenize_test() ->
{?MODULE, [{raw, "ABC"}]} = tokenize("ABC"),
View
2  src/mochifmt_records.erl
@@ -33,6 +33,6 @@ get_rec_index(Atom, [_ | Rest], Index) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochifmt_std.erl
@@ -25,6 +25,6 @@ format_field(Arg, Format) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiglobal.erl
@@ -77,8 +77,8 @@ term_to_abstract(Module, Getter, T) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
get_put_delete_test() ->
K = '$$test$$mochiglobal',
delete(K),
View
2  src/mochihex.erl
@@ -68,8 +68,8 @@ to_bin([C1, C2 | Rest], Acc) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
to_hex_test() ->
"ff000ff1" = to_hex([255, 0, 15, 241]),
View
2  src/mochijson.erl
@@ -406,8 +406,8 @@ tokenize(L=[C | _], S) when C >= $0, C =< $9; C == $- ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
%% testing constructs borrowed from the Yaws JSON implementation.
View
3  src/mochijson2.erl
@@ -527,9 +527,8 @@ tokenize(B, S=#decoder{offset=O}) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
-
+-include_lib("eunit/include/eunit.hrl").
%% testing constructs borrowed from the Yaws JSON implementation.
View
2  src/mochilists.erl
@@ -55,8 +55,8 @@ get_value(Key, Proplist, Default) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
set_defaults_test() ->
?assertEqual(
View
2  src/mochilogfile2.erl
@@ -57,8 +57,8 @@ find_last_newline(FD, Location) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
name_test() ->
D = mochitemp:mkdtemp(),
FileName = filename:join(D, "open_close_test.log"),
View
2  src/mochinum.erl
@@ -243,8 +243,8 @@ frexp_int(F) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
int_ceil_test() ->
?assertEqual(1, int_ceil(0.0001)),
View
2  src/mochitemp.erl
@@ -135,8 +135,8 @@ normalize_dir(L) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
pushenv(L) ->
[{K, os:getenv(K)} || K <- L].
popenv(L) ->
View
2  src/mochiutf8.erl
@@ -192,8 +192,8 @@ invalid_utf8_indexes(<<>>, _N, Acc) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
binary_skip_bytes_test() ->
?assertEqual(<<"foo">>,
View
2  src/mochiweb.erl
@@ -92,8 +92,8 @@ ensure_started(App) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-record(treq, {path, body= <<>>, xreply= <<>>}).
View
2  src/mochiweb_acceptor.erl
@@ -43,6 +43,6 @@ call_loop(Loop, Socket) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_app.erl
@@ -22,6 +22,6 @@ stop(_State) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_charref.erl
@@ -287,8 +287,8 @@ entity(_) -> undefined.
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
exhaustive_entity_test() ->
T = mochiweb_cover:clause_lookup_table(?MODULE, entity),
View
2  src/mochiweb_cookies.erl
@@ -203,8 +203,8 @@ any_to_list(V) when is_integer(V) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
quote_test() ->
%% ?assertError eunit macro is not compatible with coverage module
View
4 src/mochiweb_cover.erl
@@ -46,8 +46,6 @@ clause_fold(_, Acc) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
--ifdef(TEST).
foo_table(a) -> b;
foo_table("a") -> <<"b">>;
foo_table(123) -> {4, 3, 2};
@@ -56,6 +54,8 @@ foo_table([list1, list2]) -> [list1, list2, list3];
foo_table(ignored) -> some, code, ignored;
foo_table(Var) -> Var.
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
foo_table_test() ->
T = clause_lookup_table(?MODULE, foo_table),
[?assertEqual(V, foo_table(K)) || {K, V} <- T].
View
2  src/mochiweb_echo.erl
@@ -33,6 +33,6 @@ loop(Socket) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_headers.erl
@@ -195,8 +195,8 @@ any_to_list(V) when is_integer(V) ->
%%
%% Tests.
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
make_test() ->
Identity = make([{hdr, foo}]),
View
2  src/mochiweb_html.erl
@@ -759,8 +759,8 @@ tokenize_textarea(Bin, S=#decoder{offset=O}, Start) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
to_html_test() ->
?assertEqual(
View
2  src/mochiweb_http.erl
@@ -213,8 +213,8 @@ range_skip_length(Spec, Size) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
range_test() ->
%% valid, single ranges
View
2  src/mochiweb_io.erl
@@ -38,8 +38,8 @@ iodevice_size(IoDevice) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
View
2  src/mochiweb_mime.erl
@@ -75,8 +75,8 @@ from_extension(_) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
exhaustive_from_extension_test() ->
T = mochiweb_cover:clause_lookup_table(?MODULE, from_extension),
View
2  src/mochiweb_multipart.erl
@@ -295,8 +295,8 @@ find_boundary(Prefix, Data) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
ssl_cert_opts() ->
EbinDir = filename:dirname(code:which(?MODULE)),
View
2  src/mochiweb_request.erl
@@ -711,6 +711,6 @@ accepted_encodings(SupportedEncodings) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_response.erl
@@ -59,6 +59,6 @@ write_chunk(Data) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_skel.erl
@@ -81,6 +81,6 @@ ensuredir(Dir) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_socket_server.erl
@@ -337,8 +337,8 @@ handle_info(Info, State) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
upgrade_state_test() ->
OldState = {mochiweb_socket_server,
View
2  src/mochiweb_sup.erl
@@ -36,6 +36,6 @@ init([]) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
2  src/mochiweb_util.erl
@@ -548,8 +548,8 @@ make_io(Io) when is_list(Io); is_binary(Io) ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
make_io_test() ->
?assertEqual(
View
2  src/reloader.erl
@@ -156,6 +156,6 @@ stamp() ->
%%
%% Tests
%%
--include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
-endif.
View
3  support/run_tests.escript
@@ -31,7 +31,8 @@ start_cover(Modules) ->
io:format("Cover compiling...~n"),
Compiled = [ M || {ok, M} <- [ cover:compile(
M,
- [{i, "include"}
+ [{i, "include"},
+ {d, 'TEST'}
])
|| M <- Modules ] ],
case length(Modules) == length(Compiled) of
Something went wrong with that request. Please try again.