diff options
Diffstat (limited to 'lib/eunit')
-rw-r--r-- | lib/eunit/doc/overview.edoc | 13 | ||||
-rw-r--r-- | lib/eunit/doc/src/book.xml | 2 | ||||
-rw-r--r-- | lib/eunit/doc/src/notes.xml | 78 | ||||
-rw-r--r-- | lib/eunit/doc/src/part.xml | 2 | ||||
-rw-r--r-- | lib/eunit/doc/src/part_notes.xml | 2 | ||||
-rw-r--r-- | lib/eunit/doc/src/ref_man.xml | 2 | ||||
-rw-r--r-- | lib/eunit/include/eunit.hrl | 15 | ||||
-rw-r--r-- | lib/eunit/src/eunit.appup.src | 2 | ||||
-rw-r--r-- | lib/eunit/src/eunit_data.erl | 1 | ||||
-rw-r--r-- | lib/eunit/src/eunit_lib.erl | 2 | ||||
-rw-r--r-- | lib/eunit/src/eunit_listener.erl | 37 | ||||
-rw-r--r-- | lib/eunit/src/eunit_proc.erl | 2 | ||||
-rw-r--r-- | lib/eunit/src/eunit_serial.erl | 18 | ||||
-rw-r--r-- | lib/eunit/src/eunit_surefire.erl | 6 | ||||
-rw-r--r-- | lib/eunit/src/eunit_test.erl | 3 | ||||
-rw-r--r-- | lib/eunit/src/eunit_tests.erl | 2 | ||||
-rw-r--r-- | lib/eunit/src/eunit_tty.erl | 2 | ||||
-rw-r--r-- | lib/eunit/test/Makefile | 6 | ||||
-rw-r--r-- | lib/eunit/test/eunit_SUITE.erl | 2 | ||||
-rw-r--r-- | lib/eunit/vsn.mk | 2 |
20 files changed, 151 insertions, 48 deletions
diff --git a/lib/eunit/doc/overview.edoc b/lib/eunit/doc/overview.edoc index df716cdeea..3a46e991cb 100644 --- a/lib/eunit/doc/overview.edoc +++ b/lib/eunit/doc/overview.edoc @@ -690,9 +690,12 @@ it like `debugMsg'. The result is always `ok'.</dd> <dt>`debugVal(Expr)'</dt> <dd>Prints both the source code for `Expr' and its current value. E.g., `?debugVal(f(X))' might be displayed as "`f(X) = 42'". (Large terms are -shown truncated.) The result is always the value of `Expr', so this -macro can be wrapped around any expression to display its value when -the code is compiled with debugging enabled.</dd> +truncated to the depth given by the macro `EUNIT_DEBUG_VAL_DEPTH', which +defaults to 15 but can be overridden by the user.) The result is always the +value of `Expr', so this macro can be wrapped around any expression to +display its value when the code is compiled with debugging enabled.</dd> +<dt>`debugVal(Expr, Depth)'</dt> +<dd>Like `debugVal(Expr)', but prints terms truncated to the given depth.</dd> <dt>`debugTime(Text,Expr)'</dt> <dd>Prints `Text' and the wall clock time for evaluation of `Expr'. The result is always the value of `Expr', so this macro can be wrapped @@ -885,7 +888,7 @@ the timeout is exceeded, the unfinished tests will be forced to terminate. Note that if a timeout is set around a fixture, it includes the time for setup and cleanup, and if the timeout is triggered, the entire fixture is abruptly terminated (without running the -cleanup).</dd> +cleanup). The default timeout for an individual test is 5 seconds.</dd> <dt>`{inorder, Tests}'</dt> <dd>Runs the specified tests in strict order. Also see `{inparallel, Tests}'. By default, tests are neither marked as `inorder' or @@ -907,7 +910,6 @@ the test set is finished, regardless of the outcome (success, failures, timeouts, etc.). To make the descriptions simpler, we first list some definitions: -<center> <table border="0" cellspacing="4"> <tr> <td>`Setup'</td><td>`() -> (R::any())'</td> @@ -928,7 +930,6 @@ To make the descriptions simpler, we first list some definitions: <td>`Where'</td><td>`local | spawn | {spawn, Node::atom()}'</td> </tr> </table> -</center> (these are explained in more detail further below.) The following representations specify fixture handling for test sets: diff --git a/lib/eunit/doc/src/book.xml b/lib/eunit/doc/src/book.xml index 6cd2b93c68..795fce2239 100644 --- a/lib/eunit/doc/src/book.xml +++ b/lib/eunit/doc/src/book.xml @@ -5,7 +5,7 @@ <header titlestyle="normal"> <copyright> <year>2008</year> - <year>2013</year> + <year>2016</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/eunit/doc/src/notes.xml b/lib/eunit/doc/src/notes.xml index d4ffb30967..6ae3c04bc8 100644 --- a/lib/eunit/doc/src/notes.xml +++ b/lib/eunit/doc/src/notes.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2008</year> - <year>2013</year> + <year>2016</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -33,6 +33,82 @@ </header> <p>This document describes the changes made to the EUnit application.</p> +<section><title>Eunit 2.3.1</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + When asserts were moved out to a separate header file, + the automatic enabling of asserts when testing is enabled + stopped working.</p> + <p> + Own Id: OTP-13892</p> + </item> + </list> + </section> + +</section> + +<section><title>Eunit 2.3</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p>There is a new <c>debugVal/2</c> that gives control + over the truncation depth.</p> + <p> + Own Id: OTP-13612</p> + </item> + </list> + </section> + +</section> + +<section><title>Eunit 2.2.13</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> Suppress Dialyzer warnings. </p> + <p> + Own Id: OTP-12862</p> + </item> + </list> + </section> + +</section> + +<section><title>Eunit 2.2.12</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Small documentation fixes</p> + <p> + Own Id: OTP-13017</p> + </item> + </list> + </section> + +</section> + +<section><title>Eunit 2.2.11</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Improve success message when 2 tests have passed</p> + <p> + Own Id: OTP-12952</p> + </item> + </list> + </section> + +</section> + <section><title>Eunit 2.2.10</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/eunit/doc/src/part.xml b/lib/eunit/doc/src/part.xml index a4484c2c23..ac5db0e8d7 100644 --- a/lib/eunit/doc/src/part.xml +++ b/lib/eunit/doc/src/part.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2008</year> - <year>2013</year> + <year>2016</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/eunit/doc/src/part_notes.xml b/lib/eunit/doc/src/part_notes.xml index fbecfe3f11..7db65083e0 100644 --- a/lib/eunit/doc/src/part_notes.xml +++ b/lib/eunit/doc/src/part_notes.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2008</year> - <year>2013</year> + <year>2016</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/eunit/doc/src/ref_man.xml b/lib/eunit/doc/src/ref_man.xml index c573df2a4f..a02ccc69b7 100644 --- a/lib/eunit/doc/src/ref_man.xml +++ b/lib/eunit/doc/src/ref_man.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2008</year> - <year>2013</year> + <year>2016</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/eunit/include/eunit.hrl b/lib/eunit/include/eunit.hrl index ef617f075f..0f7a15f669 100644 --- a/lib/eunit/include/eunit.hrl +++ b/lib/eunit/include/eunit.hrl @@ -51,7 +51,9 @@ %% note that the main switch used within this file is NOTEST; however, %% both TEST and EUNIT may be used to check whether testing is enabled -ifndef(NOTEST). --undef(NOASSERT). % testing requires that assertions are enabled +-ifndef(ASSERT). +-define(ASSERT, true). % testing requires that assertions are enabled +-endif. -ifndef(TEST). -define(TEST, true). -endif. @@ -135,7 +137,6 @@ -define(_assertThrow(Term, Expr), ?_assertException(throw, Term, Expr)). -define(_assertNotException(Class, Term, Expr), ?_test(?assertNotException(Class, Term, Expr))). --define(_assertReceive(Guard, Expr), ?_test(?assertReceive(Guard, Expr))). %% Macros for running operating system commands. (Note that these %% require EUnit to be present at runtime, or at least eunit_lib.) @@ -213,6 +214,7 @@ -define(debugHere, ok). -define(debugFmt(S, As), ok). -define(debugVal(E), (E)). +-define(debugValAll(E), (E)). -define(debugTime(S, E), (E)). -else. -define(debugMsg(S), @@ -223,13 +225,18 @@ end). -define(debugHere, (?debugMsg("<-"))). -define(debugFmt(S, As), (?debugMsg(io_lib:format((S), (As))))). --define(debugVal(E), +-define(debugVal(E, D), begin ((fun (__V) -> - ?debugFmt(<<"~ts = ~tP">>, [(??E), __V, 15]), + ?debugFmt(<<"~ts = ~tP">>, + [(??E), __V, D]), __V end)(E)) end). +-ifndef(EUNIT_DEBUG_VAL_DEPTH). +-define(EUNIT_DEBUG_VAL_DEPTH, 15). +-endif. +-define(debugVal(E), ?debugVal(E, ?EUNIT_DEBUG_VAL_DEPTH)). -define(debugTime(S, E), begin ((fun () -> diff --git a/lib/eunit/src/eunit.appup.src b/lib/eunit/src/eunit.appup.src index 12dff80521..4f212084a2 100644 --- a/lib/eunit/src/eunit.appup.src +++ b/lib/eunit/src/eunit.appup.src @@ -1,7 +1,7 @@ %% -*- erlang -*- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2014. All Rights Reserved. +%% Copyright Ericsson AB 2014-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/lib/eunit/src/eunit_data.erl b/lib/eunit/src/eunit_data.erl index 2621e6bb8b..cea7bcd5c5 100644 --- a/lib/eunit/src/eunit_data.erl +++ b/lib/eunit/src/eunit_data.erl @@ -761,6 +761,7 @@ lazy_test_() -> lazy_gen(7), ?_assertMatch(7, get(count))]}. +-dialyzer({no_improper_lists, lazy_gen/1}). lazy_gen(N) -> {generator, fun () -> diff --git a/lib/eunit/src/eunit_lib.erl b/lib/eunit/src/eunit_lib.erl index 914e48c062..b19f50b990 100644 --- a/lib/eunit/src/eunit_lib.erl +++ b/lib/eunit/src/eunit_lib.erl @@ -399,6 +399,7 @@ uniq([X | Xs]) -> [X | uniq(Xs)]; uniq([]) -> []. -ifdef(TEST). +-dialyzer({[no_fail_call, no_improper_lists], uniq_test_/0}). uniq_test_() -> {"uniq", [?_assertError(function_clause, uniq(ok)), @@ -459,6 +460,7 @@ normalize([]) -> -ifdef(TEST). +-dialyzer({no_match, cmd_test_/0}). cmd_test_() -> ([?_test({0, "hello\n"} = ?_cmd_("echo hello"))] ++ case os:type() of diff --git a/lib/eunit/src/eunit_listener.erl b/lib/eunit/src/eunit_listener.erl index ecaac424a2..c34eacb1d6 100644 --- a/lib/eunit/src/eunit_listener.erl +++ b/lib/eunit/src/eunit_listener.erl @@ -27,14 +27,11 @@ -export([start/1, start/2]). --export([behaviour_info/1]). - - -behaviour_info(callbacks) -> - [{init,1},{handle_begin,3},{handle_end,3},{handle_cancel,3}, - {terminate,2}]; -behaviour_info(_Other) -> - undefined. +-callback init(_) -> _. +-callback handle_begin(_, _, _) -> _. +-callback handle_end(_, _, _) -> _. +-callback handle_cancel(_, _, _) -> _. +-callback terminate(_, _) -> _. -record(state, {callback, % callback module @@ -50,18 +47,22 @@ start(Callback) -> start(Callback, Options) -> St = #state{callback = Callback}, - spawn_opt(fun () -> init(St, Options) end, + spawn_opt(init_fun(St, Options), proplists:get_all_values(spawn, Options)). -init(St0, Options) -> - St1 = call(init, [Options], St0), - St2 = expect([], undefined, St1), - Data = [{pass, St2#state.pass}, - {fail, St2#state.fail}, - {skip, St2#state.skip}, - {cancel, St2#state.cancel}], - call(terminate, [{ok, Data}, St2#state.state], St2), - exit(normal). +-spec init_fun(_, _) -> fun(() -> no_return()). + +init_fun(St0, Options) -> + fun () -> + St1 = call(init, [Options], St0), + St2 = expect([], undefined, St1), + Data = [{pass, St2#state.pass}, + {fail, St2#state.fail}, + {skip, St2#state.skip}, + {cancel, St2#state.cancel}], + call(terminate, [{ok, Data}, St2#state.state], St2), + exit(normal) + end. expect(Id, ParentId, St) -> case wait_for(Id, 'begin', ParentId) of diff --git a/lib/eunit/src/eunit_proc.erl b/lib/eunit/src/eunit_proc.erl index 2f3ffd4b8a..c6bb8bdbb3 100644 --- a/lib/eunit/src/eunit_proc.erl +++ b/lib/eunit/src/eunit_proc.erl @@ -268,6 +268,8 @@ insulator_wait(Child, Parent, Buf, St) -> kill_task(Child, St) end. +-spec kill_task(_, _) -> no_return(). + kill_task(Child, St) -> exit(Child, kill), terminate_insulator(St). diff --git a/lib/eunit/src/eunit_serial.erl b/lib/eunit/src/eunit_serial.erl index 0289a7c834..bbda4400da 100644 --- a/lib/eunit/src/eunit_serial.erl +++ b/lib/eunit/src/eunit_serial.erl @@ -61,14 +61,16 @@ messages = dict:new() :: dict:dict()}). start(Pids) -> - spawn(fun () -> serializer(Pids) end). - -serializer(Pids) -> - St = #state{listeners = sets:from_list(Pids), - cancelled = eunit_lib:trie_new(), - messages = dict:new()}, - expect([], undefined, 0, St), - exit(normal). + spawn(serializer_fun(Pids)). + +serializer_fun(Pids) -> + fun () -> + St = #state{listeners = sets:from_list(Pids), + cancelled = eunit_lib:trie_new(), + messages = dict:new()}, + expect([], undefined, 0, St), + exit(normal) + end. %% collect beginning and end of an expected item; return {Done, NewSt} %% where Done is true if there are no more items of this group diff --git a/lib/eunit/src/eunit_surefire.erl b/lib/eunit/src/eunit_surefire.erl index 0a6e5272c7..a70b8bfd4c 100644 --- a/lib/eunit/src/eunit_surefire.erl +++ b/lib/eunit/src/eunit_surefire.erl @@ -56,7 +56,11 @@ { name :: chars(), description :: chars(), - result :: ok | {failed, tuple()} | {aborted, tuple()} | {skipped, term()}, + result :: ok + | {failed, tuple()} + | {aborted, tuple()} + | {skipped, term()} + | undefined, time :: integer(), output :: binary() }). diff --git a/lib/eunit/src/eunit_test.erl b/lib/eunit/src/eunit_test.erl index 5db3d95e91..f2b9fa46f2 100644 --- a/lib/eunit/src/eunit_test.erl +++ b/lib/eunit/src/eunit_test.erl @@ -40,6 +40,7 @@ get_stacktrace() -> get_stacktrace(Ts) -> eunit_lib:uniq(prune_trace(erlang:get_stacktrace(), Ts)). +-dialyzer({no_match, prune_trace/2}). prune_trace([{eunit_data, _, _} | Rest], Tail) -> prune_trace(Rest, Tail); prune_trace([{eunit_data, _, _, _} | Rest], Tail) -> @@ -75,6 +76,7 @@ run_testfun(F) -> -ifdef(TEST). +-dialyzer({[no_match, no_fail_call, no_return], macro_test_/0}). macro_test_() -> {"macro definitions", [{?LINE, fun () -> @@ -301,6 +303,7 @@ wrapper_test_() -> ]}. %% this must be exported (done automatically by the autoexport transform) +-dialyzer({no_missing_calls, wrapper_test_exported_/0}). wrapper_test_exported_() -> {ok, ?MODULE:nonexisting_function()}. -endif. diff --git a/lib/eunit/src/eunit_tests.erl b/lib/eunit/src/eunit_tests.erl index c83e0322f7..7aadefb29f 100644 --- a/lib/eunit/src/eunit_tests.erl +++ b/lib/eunit/src/eunit_tests.erl @@ -23,6 +23,8 @@ -include("eunit.hrl"). +-dialyzer(no_match). + -ifdef(TEST). id(X) -> X. % for suppressing compiler warnings -endif. diff --git a/lib/eunit/src/eunit_tty.erl b/lib/eunit/src/eunit_tty.erl index 22ee035b7c..1fbc4edd45 100644 --- a/lib/eunit/src/eunit_tty.erl +++ b/lib/eunit/src/eunit_tty.erl @@ -67,6 +67,8 @@ terminate({ok, Data}, St) -> end, if Pass =:= 1 -> fwrite(" Test passed.\n"); + Pass =:= 2 -> + fwrite(" 2 tests passed.\n"); true -> fwrite(" All ~w tests passed.\n", [Pass]) end diff --git a/lib/eunit/test/Makefile b/lib/eunit/test/Makefile index 8721bacf89..b6ece61b43 100644 --- a/lib/eunit/test/Makefile +++ b/lib/eunit/test/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 2009-2012. All Rights Reserved. +# Copyright Ericsson AB 2009-2016. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -41,8 +41,8 @@ RELSYSDIR = $(RELEASE_PATH)/eunit_test # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- -ERL_MAKE_FLAGS += -pa $(ERL_TOP)/lib/test_server/ebin -ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/test_server/include +ERL_MAKE_FLAGS += +ERL_COMPILE_FLAGS += EBIN = . diff --git a/lib/eunit/test/eunit_SUITE.erl b/lib/eunit/test/eunit_SUITE.erl index 9897d5ae2b..63bdc6c334 100644 --- a/lib/eunit/test/eunit_SUITE.erl +++ b/lib/eunit/test/eunit_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2011. All Rights Reserved. +%% Copyright Ericsson AB 2010-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/lib/eunit/vsn.mk b/lib/eunit/vsn.mk index 8b489bdc04..83d826f8b6 100644 --- a/lib/eunit/vsn.mk +++ b/lib/eunit/vsn.mk @@ -1 +1 @@ -EUNIT_VSN = 2.2.10 +EUNIT_VSN = 2.3.1 |