couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r780326 - in /couchdb/trunk: Makefile.am THANKS configure.ac src/couchdb/Makefile.am src/couchdb/couch_btree.erl src/ibrowse/Makefile.am src/mochiweb/Makefile.am test/etap/030-doc-from-json.t
Date Sat, 30 May 2009 21:12:07 GMT
Author: davisp
Date: Sat May 30 21:12:06 2009
New Revision: 780326

URL: http://svn.apache.org/viewvc?rev=780326&view=rev
Log:
Added code coverage report generation target.

To generate reports:

    # Assuming etap is installed
    $ cd /path/to/couchdb
    $ ./bootstrap && ERLC_FLAGS=+debug_info ./configure && make cover

You can browse the report by opening ./cover/index.html in your html consuming software of
choice.

Shoutout to Nick Gerakines in THANKS for helping with etap and testing in general.


Modified:
    couchdb/trunk/Makefile.am
    couchdb/trunk/THANKS
    couchdb/trunk/configure.ac
    couchdb/trunk/src/couchdb/Makefile.am
    couchdb/trunk/src/couchdb/couch_btree.erl
    couchdb/trunk/src/ibrowse/Makefile.am
    couchdb/trunk/src/mochiweb/Makefile.am
    couchdb/trunk/test/etap/030-doc-from-json.t

Modified: couchdb/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/Makefile.am?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/Makefile.am (original)
+++ couchdb/trunk/Makefile.am Sat May 30 21:12:06 2009
@@ -39,6 +39,13 @@
 check: all
 	prove test/etap/*.t
 
+cover: all
+	rm -f cover/*.coverdata
+	COVER=1 COVER_BIN=./src/couchdb/ prove test/etap/*.t
+	SRC=./src/couchdb/ \
+	    $(ERL) -noshell -eval 'etap_report:create()' \
+	    -s init stop -noshell > /dev/null 2>&1
+
 dev: all
 	@echo "This command is intended for developers to use;"
 	@echo "it creates development ini files as well as a"

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Sat May 30 21:12:06 2009
@@ -28,5 +28,6 @@
  * Volker Mische <volker.mische@gmail.com>
  * Brian Candler <B.Candler@pobox.com>
  * Brad Anderson <brad@sankatygroup.com>
+ * Nick Gerakines <nick@gerakines.net>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/configure.ac
URL: http://svn.apache.org/viewvc/couchdb/trunk/configure.ac?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/configure.ac (original)
+++ couchdb/trunk/configure.ac Sat May 30 21:12:06 2009
@@ -74,6 +74,7 @@
     [set PATH to the SpiderMonkey library directory])],
     [JS_LIB_FLAGS="-L$withval"], [])
 
+AC_ARG_VAR([ERLC_FLAGS], [general flags to prepend to ERLC_FLAGS])
 AC_ARG_VAR([FLAGS], [general flags to prepend to LDFLAGS and CPPFLAGS])
 
 LIB_FLAGS="$JS_LIB_FLAGS -L/usr/local/lib -L/opt/local/lib"

Modified: couchdb/trunk/src/couchdb/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/Makefile.am?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/Makefile.am (original)
+++ couchdb/trunk/src/couchdb/Makefile.am Sat May 30 21:12:06 2009
@@ -169,7 +169,7 @@
 # $(ERL) -noshell -run edoc_run files [\"$<\"]
 
 %.beam: %.erl couch_db.hrl
-	$(ERLC) ${TEST} $<;
+	$(ERLC) $(ERLC_FLAGS) ${TEST} $<;
 
 install-data-hook:
 	if test -f "$(DESTDIR)/$(couchprivlibdir)/couch_erl_driver"; then \

Modified: couchdb/trunk/src/couchdb/couch_btree.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_btree.erl?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_btree.erl (original)
+++ couchdb/trunk/src/couchdb/couch_btree.erl Sat May 30 21:12:06 2009
@@ -15,7 +15,6 @@
 -export([open/2, open/3, query_modify/4, add/2, add_remove/3, foldl/3, foldl/4]).
 -export([foldr/3, foldr/4, fold/4, fold/5, full_reduce/1, final_reduce/2]).
 -export([fold_reduce/6, fold_reduce/7, lookup/2, get_state/1, set_options/2]).
--export([test/1, test/0, test_remove/2, test_add/2]).
 
 -define(CHUNK_THRESHOLD, 16#4ff).
 
@@ -652,217 +651,3 @@
     {stop, Acc2} ->
         {stop, Acc2}
     end.
-
-shuffle(List) ->
-%% Determine the log n portion then randomize the list.
-   randomize(round(math:log(length(List)) + 0.5), List).
-
-randomize(1, List) ->
-   randomize(List);
-randomize(T, List) ->
-   lists:foldl(fun(_E, Acc) ->
-                  randomize(Acc)
-               end, randomize(List), lists:seq(1, (T - 1))).
-
-randomize(List) ->
-   D = lists:map(fun(A) ->
-                    {random:uniform(), A}
-             end, List),
-   {_, D1} = lists:unzip(lists:keysort(1, D)), 
-   D1.
-
-
-
-test()->
-    test(1000).
-
-test(N) ->
-    Sorted = [{Seq, random:uniform()} || Seq <- lists:seq(1, N)],
-    test_btree(Sorted),                 % sorted regular
-    test_btree(lists:reverse(Sorted)),  % sorted reverse
-    test_btree(shuffle(Sorted)).   % randomly distributed
-
-
-test_btree(KeyValues) ->
-    {ok, Fd} = couch_file:open("foo", [create,overwrite]),
-    {ok, Btree} = open(nil, Fd),
-    ReduceFun =
-        fun(reduce, KVs) ->
-            length(KVs);
-        (rereduce, Reds) ->
-            lists:sum(Reds)
-        end,
-    Btree1 = set_options(Btree, [{reduce, ReduceFun}]),
-
-    % first dump in all the values in one go
-    {ok, Btree10} = add_remove(Btree1, KeyValues, []),
-
-    
-    Len = length(KeyValues),
-
-    % get the leading reduction as we foldl/r
-    % and count of all from start to Val1
-    Val1 = Len div 3,
-    {ok, _} = foldl(Btree10, Val1,
-        fun(_X, LeadingReds, Acc) ->
-            CountToStart = Val1 + Acc - 1,
-            CountToStart = final_reduce(Btree10, LeadingReds),
-            {ok, Acc + 1}
-        end,
-        0),
-
-    {ok, true} = foldr(Btree10, Val1, fun(_X, LeadingReds, _Acc) ->
-            CountToEnd = Len - Val1,
-            CountToEnd = final_reduce(Btree10, LeadingReds),
-            {stop, true} % change Acc to 'true'
-        end,
-        false),
-            
-    ok = test_keys(Btree10, KeyValues),
-
-    % remove everything
-    {ok, Btree20} = test_remove(Btree10, KeyValues),
-
-    % make sure its empty
-    {ok, false} = foldl(Btree20, fun(_X, _Acc) ->
-            {ok, true} % change Acc to 'true'
-        end,
-        false),
-
-    % add everything back one at a time.
-    {ok, Btree30} = test_add(Btree20, KeyValues),
-
-    ok = test_keys(Btree30, KeyValues),
-
-    KeyValuesRev = lists:reverse(KeyValues),
-
-    % remove everything, in reverse order
-    {ok, Btree40} = test_remove(Btree30, KeyValuesRev),
-
-    % make sure its empty
-    {ok, false} = foldl(Btree40, fun(_X, _Acc) ->
-            {ok, true} % change Acc to 'true'
-        end,
-        false),
-
-
-    {A, B} = every_other(KeyValues),
-
-    % add everything back
-    {ok, Btree50} = test_add(Btree40,KeyValues),
-
-    ok = test_keys(Btree50, KeyValues),
-
-    % remove half the values
-    {ok, Btree60} = test_remove(Btree50, A),
-
-    % verify the remaining
-    ok = test_keys(Btree60, B),
-
-    % add A back
-    {ok, Btree70} = test_add(Btree60, A),
-
-    % verify
-    ok = test_keys(Btree70, KeyValues),
-
-    % remove B
-    {ok, Btree80} = test_remove(Btree70, B),
-
-    % verify the remaining
-    ok = test_keys(Btree80, A),
-    
-    {ok, Btree90} = test_remove(Btree80, A),
-    
-    EvenOdd = fun(V) when V rem 2 == 1 -> "odd"; (_) -> "even" end,
-    
-    EvenOddKVs = [{{EvenOdd(Key),Key}, 1} || {Key, _} <- KeyValues],
-
-    {ok, Btree100} = test_add(Btree90, EvenOddKVs),
-    GroupingFun = fun({K1, _},{K2,_}) -> K1 == K2 end,
-    FoldFun = fun(GroupedKey, Unreduced, Acc) ->
-            {ok, [{GroupedKey, final_reduce(Btree100, Unreduced)} | Acc]}
-        end,
-        
-    Half = Len div 2,
-    
-    {ok, [{{"odd", _}, Half}, {{"even",_}, Half}]} =
-        fold_reduce(Btree100, nil, nil, GroupingFun, FoldFun, []),
-    
-    {ok, [{{"even",_}, Half}, {{"odd", _}, Half}]} =
-        fold_reduce(Btree100, rev, nil, nil, GroupingFun, FoldFun, []),
-        
-    {ok, [{{"even",_}, Half}]} =
-        fold_reduce(Btree100, fwd, {"even", -1}, {"even", foo}, GroupingFun, FoldFun, []),
-        
-    {ok, [{{"even",_}, Half}]} =
-        fold_reduce(Btree100, rev, {"even", foo}, {"even", -1}, GroupingFun, FoldFun, []),
-        
-    {ok, [{{"odd",_}, Half}]} =
-        fold_reduce(Btree100, fwd, {"odd", -1}, {"odd", foo}, GroupingFun, FoldFun, []),
-    
-    {ok, [{{"odd",_}, Half}]} =
-        fold_reduce(Btree100, rev, {"odd", foo}, {"odd", -1}, GroupingFun, FoldFun, []),
-    
-    {ok, [{{"odd", _}, Half}, {{"even",_}, Half}]} =
-        fold_reduce(Btree100, {"even", -1}, {"odd", foo}, GroupingFun, FoldFun, []),
-    
-    ok = couch_file:close(Fd).
-    
-
-
-
-
-every_other(List) ->
-    every_other(List, [], [], 1).
-
-every_other([], AccA, AccB, _Flag) ->
-    {lists:reverse(AccA), lists:reverse(AccB)};
-every_other([H|T], AccA, AccB, 1) ->
-    every_other(T, [H|AccA], AccB, 0);
-every_other([H|T], AccA, AccB, 0) ->
-    every_other(T, AccA, [H|AccB], 1).
-
-test_keys(Btree, List) ->
-    FoldFun =
-    fun(Element, [HAcc|TAcc]) ->
-            Element = HAcc, % must match
-            {ok, TAcc}
-        end,
-    Sorted = lists:sort(List),
-    {ok, []} = foldl(Btree, FoldFun, Sorted),
-    {ok, []} = foldr(Btree, FoldFun, lists:reverse(Sorted)),
-
-    test_lookup(Btree, List).
-
-% Makes sure each key value pair is found in the btree
-test_lookup(_Btree, []) ->
-    ok;
-test_lookup(Btree, [{Key, Value} | Rest]) ->
-    [{ok,{Key, Value}}] = lookup(Btree, [Key]),
-    {ok, []} = foldl(Btree, Key, fun({KeyIn, ValueIn}, []) ->
-            KeyIn = Key,
-            ValueIn = Value,
-            {stop, []}
-        end,
-        []),
-    {ok, []} = foldr(Btree, Key, fun({KeyIn, ValueIn}, []) ->
-            KeyIn = Key,
-            ValueIn = Value,
-            {stop, []}
-        end,
-        []),
-    test_lookup(Btree, Rest).
-
-% removes each key one at a time from the btree
-test_remove(Btree, []) ->
-    {ok, Btree};
-test_remove(Btree, [{Key, _Value} | Rest]) ->
-    {ok, Btree2} = add_remove(Btree,[], [Key]),
-    test_remove(Btree2, Rest).
-
-% adds each key one at a time from the btree
-test_add(Btree, []) ->
-    {ok, Btree};
-test_add(Btree, [KeyValue | Rest]) ->
-    {ok, Btree2} = add_remove(Btree, [KeyValue], []),
-    test_add(Btree2, Rest).

Modified: couchdb/trunk/src/ibrowse/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/ibrowse/Makefile.am?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/src/ibrowse/Makefile.am (original)
+++ couchdb/trunk/src/ibrowse/Makefile.am Sat May 30 21:12:06 2009
@@ -45,4 +45,4 @@
     $(ibrowseebin_make_generated_file_list)
 
 %.beam: %.erl
-	$(ERLC) $<
+	$(ERLC) $(ERLC_FLAGS) $<

Modified: couchdb/trunk/src/mochiweb/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/mochiweb/Makefile.am?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/src/mochiweb/Makefile.am (original)
+++ couchdb/trunk/src/mochiweb/Makefile.am Sat May 30 21:12:06 2009
@@ -76,4 +76,4 @@
     $(mochiwebebin_make_generated_file_list)
 
 %.beam: %.erl
-	$(ERLC) $<
+	$(ERLC) $(ERLC_FLAGS) $<

Modified: couchdb/trunk/test/etap/030-doc-from-json.t
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/030-doc-from-json.t?rev=780326&r1=780325&r2=780326&view=diff
==============================================================================
--- couchdb/trunk/test/etap/030-doc-from-json.t (original)
+++ couchdb/trunk/test/etap/030-doc-from-json.t Sat May 30 21:12:06 2009
@@ -87,11 +87,11 @@
         },
         {
             {[
-                {<<"_rev">>, <<"6-something">>},
                 {<<"_revisions">>, {[
                     {<<"start">>, 4},
                     {<<"ids">>, [<<"foo1">>, <<"phi3">>,
<<"omega">>]}
-                ]}}
+                ]}},
+                {<<"_rev">>, <<"6-something">>}
             ]},
             #doc{revs={4, [<<"foo1">>, <<"phi3">>, <<"omega">>]}},
             "_revisions attribute are preferred to _rev."



Mime
View raw message