Skip to content
This repository

Make Eunit optional #22

Closed
wants to merge 2 commits into from

4 participants

Robert Newson Bob Ippolito Peter Lemenkov David Reid
Robert Newson

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

Bob Ippolito
Owner

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

Robert Newson

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

Bob Ippolito
Owner

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

Peter Lemenkov
Collaborator

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

Peter 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.

Robert Newson

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.

David Reid
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.

Bob Ippolito
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.

Bob Ippolito
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

Showing 2 unique commits by 1 author.

Nov 08, 2010
make eunit completely optional. 9b896d3
Nov 11, 2010
fix mochiweb_cover.erl test in an ugly way. 550cbed
This page is out of date. Refresh to see the latest.
2  src/mochifmt.erl
@@ -369,8 +369,8 @@ parse_std_conversion([Type], Acc) ->
369 369
 %%
370 370
 %% Tests
371 371
 %%
372  
--include_lib("eunit/include/eunit.hrl").
373 372
 -ifdef(TEST).
  373
+-include_lib("eunit/include/eunit.hrl").
374 374
 
375 375
 tokenize_test() ->
376 376
     {?MODULE, [{raw, "ABC"}]} = tokenize("ABC"),
2  src/mochifmt_records.erl
@@ -33,6 +33,6 @@ get_rec_index(Atom, [_ | Rest], Index) ->
33 33
 %%
34 34
 %% Tests
35 35
 %%
36  
--include_lib("eunit/include/eunit.hrl").
37 36
 -ifdef(TEST).
  37
+-include_lib("eunit/include/eunit.hrl").
38 38
 -endif.
2  src/mochifmt_std.erl
@@ -25,6 +25,6 @@ format_field(Arg, Format) ->
25 25
 %%
26 26
 %% Tests
27 27
 %%
28  
--include_lib("eunit/include/eunit.hrl").
29 28
 -ifdef(TEST).
  29
+-include_lib("eunit/include/eunit.hrl").
30 30
 -endif.
2  src/mochiglobal.erl
@@ -77,8 +77,8 @@ term_to_abstract(Module, Getter, T) ->
77 77
 %%
78 78
 %% Tests
79 79
 %%
80  
--include_lib("eunit/include/eunit.hrl").
81 80
 -ifdef(TEST).
  81
+-include_lib("eunit/include/eunit.hrl").
82 82
 get_put_delete_test() ->
83 83
     K = '$$test$$mochiglobal',
84 84
     delete(K),
2  src/mochihex.erl
@@ -68,8 +68,8 @@ to_bin([C1, C2 | Rest], Acc) ->
68 68
 %%
69 69
 %% Tests
70 70
 %%
71  
--include_lib("eunit/include/eunit.hrl").
72 71
 -ifdef(TEST).
  72
+-include_lib("eunit/include/eunit.hrl").
73 73
 
74 74
 to_hex_test() ->
75 75
     "ff000ff1" = to_hex([255, 0, 15, 241]),
2  src/mochijson.erl
@@ -406,8 +406,8 @@ tokenize(L=[C | _], S) when C >= $0, C =< $9; C == $- ->
406 406
 %%
407 407
 %% Tests
408 408
 %%
409  
--include_lib("eunit/include/eunit.hrl").
410 409
 -ifdef(TEST).
  410
+-include_lib("eunit/include/eunit.hrl").
411 411
 
412 412
 %% testing constructs borrowed from the Yaws JSON implementation.
413 413
 
3  src/mochijson2.erl
@@ -527,9 +527,8 @@ tokenize(B, S=#decoder{offset=O}) ->
527 527
 %%
528 528
 %% Tests
529 529
 %%
530  
--include_lib("eunit/include/eunit.hrl").
531 530
 -ifdef(TEST).
532  
-
  531
+-include_lib("eunit/include/eunit.hrl").
533 532
 
534 533
 %% testing constructs borrowed from the Yaws JSON implementation.
535 534
 
2  src/mochilists.erl
@@ -55,8 +55,8 @@ get_value(Key, Proplist, Default) ->
55 55
 %%
56 56
 %% Tests
57 57
 %%
58  
--include_lib("eunit/include/eunit.hrl").
59 58
 -ifdef(TEST).
  59
+-include_lib("eunit/include/eunit.hrl").
60 60
 
61 61
 set_defaults_test() ->
62 62
     ?assertEqual(
2  src/mochilogfile2.erl
@@ -57,8 +57,8 @@ find_last_newline(FD, Location) ->
57 57
 %%
58 58
 %% Tests
59 59
 %%
60  
--include_lib("eunit/include/eunit.hrl").
61 60
 -ifdef(TEST).
  61
+-include_lib("eunit/include/eunit.hrl").
62 62
 name_test() ->
63 63
     D = mochitemp:mkdtemp(),
64 64
     FileName = filename:join(D, "open_close_test.log"),
2  src/mochinum.erl
@@ -243,8 +243,8 @@ frexp_int(F) ->
243 243
 %%
244 244
 %% Tests
245 245
 %%
246  
--include_lib("eunit/include/eunit.hrl").
247 246
 -ifdef(TEST).
  247
+-include_lib("eunit/include/eunit.hrl").
248 248
 
249 249
 int_ceil_test() ->
250 250
     ?assertEqual(1, int_ceil(0.0001)),
2  src/mochitemp.erl
@@ -135,8 +135,8 @@ normalize_dir(L) ->
135 135
 %%
136 136
 %% Tests
137 137
 %%
138  
--include_lib("eunit/include/eunit.hrl").
139 138
 -ifdef(TEST).
  139
+-include_lib("eunit/include/eunit.hrl").
140 140
 pushenv(L) ->
141 141
     [{K, os:getenv(K)} || K <- L].
142 142
 popenv(L) ->
2  src/mochiutf8.erl
@@ -192,8 +192,8 @@ invalid_utf8_indexes(<<>>, _N, Acc) ->
192 192
 %%
193 193
 %% Tests
194 194
 %%
195  
--include_lib("eunit/include/eunit.hrl").
196 195
 -ifdef(TEST).
  196
+-include_lib("eunit/include/eunit.hrl").
197 197
 
198 198
 binary_skip_bytes_test() ->
199 199
     ?assertEqual(<<"foo">>,
2  src/mochiweb.erl
@@ -92,8 +92,8 @@ ensure_started(App) ->
92 92
 %%
93 93
 %% Tests
94 94
 %%
95  
--include_lib("eunit/include/eunit.hrl").
96 95
 -ifdef(TEST).
  96
+-include_lib("eunit/include/eunit.hrl").
97 97
 
98 98
 -record(treq, {path, body= <<>>, xreply= <<>>}).
99 99
 
2  src/mochiweb_acceptor.erl
@@ -43,6 +43,6 @@ call_loop(Loop, Socket) ->
43 43
 %%
44 44
 %% Tests
45 45
 %%
46  
--include_lib("eunit/include/eunit.hrl").
47 46
 -ifdef(TEST).
  47
+-include_lib("eunit/include/eunit.hrl").
48 48
 -endif.
2  src/mochiweb_app.erl
@@ -22,6 +22,6 @@ stop(_State) ->
22 22
 %%
23 23
 %% Tests
24 24
 %%
25  
--include_lib("eunit/include/eunit.hrl").
26 25
 -ifdef(TEST).
  26
+-include_lib("eunit/include/eunit.hrl").
27 27
 -endif.
2  src/mochiweb_charref.erl
@@ -287,8 +287,8 @@ entity(_) -> undefined.
287 287
 %%
288 288
 %% Tests
289 289
 %%
290  
--include_lib("eunit/include/eunit.hrl").
291 290
 -ifdef(TEST).
  291
+-include_lib("eunit/include/eunit.hrl").
292 292
 
293 293
 exhaustive_entity_test() ->
294 294
     T = mochiweb_cover:clause_lookup_table(?MODULE, entity),
2  src/mochiweb_cookies.erl
@@ -203,8 +203,8 @@ any_to_list(V) when is_integer(V) ->
203 203
 %%
204 204
 %% Tests
205 205
 %%
206  
--include_lib("eunit/include/eunit.hrl").
207 206
 -ifdef(TEST).
  207
+-include_lib("eunit/include/eunit.hrl").
208 208
 
209 209
 quote_test() ->
210 210
     %% ?assertError eunit macro is not compatible with coverage module
4  src/mochiweb_cover.erl
@@ -46,8 +46,6 @@ clause_fold(_, Acc) ->
46 46
 %%
47 47
 %% Tests
48 48
 %%
49  
--include_lib("eunit/include/eunit.hrl").
50  
--ifdef(TEST).
51 49
 foo_table(a) -> b;
52 50
 foo_table("a") -> <<"b">>;
53 51
 foo_table(123) -> {4, 3, 2};
@@ -56,6 +54,8 @@ foo_table([list1, list2]) -> [list1, list2, list3];
56 54
 foo_table(ignored) -> some, code, ignored;
57 55
 foo_table(Var) -> Var.
58 56
 
  57
+-ifdef(TEST).
  58
+-include_lib("eunit/include/eunit.hrl").
59 59
 foo_table_test() ->
60 60
     T = clause_lookup_table(?MODULE, foo_table),
61 61
     [?assertEqual(V, foo_table(K)) || {K, V} <- T].
2  src/mochiweb_echo.erl
@@ -33,6 +33,6 @@ loop(Socket) ->
33 33
 %%
34 34
 %% Tests
35 35
 %%
36  
--include_lib("eunit/include/eunit.hrl").
37 36
 -ifdef(TEST).
  37
+-include_lib("eunit/include/eunit.hrl").
38 38
 -endif.
2  src/mochiweb_headers.erl
@@ -195,8 +195,8 @@ any_to_list(V) when is_integer(V) ->
195 195
 %%
196 196
 %% Tests.
197 197
 %%
198  
--include_lib("eunit/include/eunit.hrl").
199 198
 -ifdef(TEST).
  199
+-include_lib("eunit/include/eunit.hrl").
200 200
 
201 201
 make_test() ->
202 202
     Identity = make([{hdr, foo}]),
2  src/mochiweb_html.erl
@@ -759,8 +759,8 @@ tokenize_textarea(Bin, S=#decoder{offset=O}, Start) ->
759 759
 %%
760 760
 %% Tests
761 761
 %%
762  
--include_lib("eunit/include/eunit.hrl").
763 762
 -ifdef(TEST).
  763
+-include_lib("eunit/include/eunit.hrl").
764 764
 
765 765
 to_html_test() ->
766 766
     ?assertEqual(
2  src/mochiweb_http.erl
@@ -213,8 +213,8 @@ range_skip_length(Spec, Size) ->
213 213
 %%
214 214
 %% Tests
215 215
 %%
216  
--include_lib("eunit/include/eunit.hrl").
217 216
 -ifdef(TEST).
  217
+-include_lib("eunit/include/eunit.hrl").
218 218
 
219 219
 range_test() ->
220 220
     %% valid, single ranges
2  src/mochiweb_io.erl
@@ -38,8 +38,8 @@ iodevice_size(IoDevice) ->
38 38
 %%
39 39
 %% Tests
40 40
 %%
41  
--include_lib("eunit/include/eunit.hrl").
42 41
 -ifdef(TEST).
  42
+-include_lib("eunit/include/eunit.hrl").
43 43
 
44 44
 
45 45
 
2  src/mochiweb_mime.erl
@@ -75,8 +75,8 @@ from_extension(_) ->
75 75
 %%
76 76
 %% Tests
77 77
 %%
78  
--include_lib("eunit/include/eunit.hrl").
79 78
 -ifdef(TEST).
  79
+-include_lib("eunit/include/eunit.hrl").
80 80
 
81 81
 exhaustive_from_extension_test() ->
82 82
     T = mochiweb_cover:clause_lookup_table(?MODULE, from_extension),
2  src/mochiweb_multipart.erl
@@ -295,8 +295,8 @@ find_boundary(Prefix, Data) ->
295 295
 %%
296 296
 %% Tests
297 297
 %%
298  
--include_lib("eunit/include/eunit.hrl").
299 298
 -ifdef(TEST).
  299
+-include_lib("eunit/include/eunit.hrl").
300 300
 
301 301
 ssl_cert_opts() ->
302 302
     EbinDir = filename:dirname(code:which(?MODULE)),
2  src/mochiweb_request.erl
@@ -711,6 +711,6 @@ accepted_encodings(SupportedEncodings) ->
711 711
 %%
712 712
 %% Tests
713 713
 %%
714  
--include_lib("eunit/include/eunit.hrl").
715 714
 -ifdef(TEST).
  715
+-include_lib("eunit/include/eunit.hrl").
716 716
 -endif.
2  src/mochiweb_response.erl
@@ -59,6 +59,6 @@ write_chunk(Data) ->
59 59
 %%
60 60
 %% Tests
61 61
 %%
62  
--include_lib("eunit/include/eunit.hrl").
63 62
 -ifdef(TEST).
  63
+-include_lib("eunit/include/eunit.hrl").
64 64
 -endif.
2  src/mochiweb_skel.erl
@@ -81,6 +81,6 @@ ensuredir(Dir) ->
81 81
 %%
82 82
 %% Tests
83 83
 %%
84  
--include_lib("eunit/include/eunit.hrl").
85 84
 -ifdef(TEST).
  85
+-include_lib("eunit/include/eunit.hrl").
86 86
 -endif.
2  src/mochiweb_socket_server.erl
@@ -337,8 +337,8 @@ handle_info(Info, State) ->
337 337
 %%
338 338
 %% Tests
339 339
 %%
340  
--include_lib("eunit/include/eunit.hrl").
341 340
 -ifdef(TEST).
  341
+-include_lib("eunit/include/eunit.hrl").
342 342
 
343 343
 upgrade_state_test() ->
344 344
     OldState = {mochiweb_socket_server,
2  src/mochiweb_sup.erl
@@ -36,6 +36,6 @@ init([]) ->
36 36
 %%
37 37
 %% Tests
38 38
 %%
39  
--include_lib("eunit/include/eunit.hrl").
40 39
 -ifdef(TEST).
  40
+-include_lib("eunit/include/eunit.hrl").
41 41
 -endif.
2  src/mochiweb_util.erl
@@ -548,8 +548,8 @@ make_io(Io) when is_list(Io); is_binary(Io) ->
548 548
 %%
549 549
 %% Tests
550 550
 %%
551  
--include_lib("eunit/include/eunit.hrl").
552 551
 -ifdef(TEST).
  552
+-include_lib("eunit/include/eunit.hrl").
553 553
 
554 554
 make_io_test() ->
555 555
     ?assertEqual(
2  src/reloader.erl
@@ -156,6 +156,6 @@ stamp() ->
156 156
 %%
157 157
 %% Tests
158 158
 %%
159  
--include_lib("eunit/include/eunit.hrl").
160 159
 -ifdef(TEST).
  160
+-include_lib("eunit/include/eunit.hrl").
161 161
 -endif.
3  support/run_tests.escript
@@ -31,7 +31,8 @@ start_cover(Modules) ->
31 31
     io:format("Cover compiling...~n"),
32 32
     Compiled = [ M || {ok, M} <- [ cover:compile(
33 33
                                      M,
34  
-                                     [{i, "include"}
  34
+                                     [{i, "include"},
  35
+                                      {d, 'TEST'}
35 36
                                      ])
36 37
                                    || M <- Modules ] ],
37 38
     case length(Modules) == length(Compiled) of
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.