Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix EUnit failures that should've been fixed before merging jdb-faste…

…r-slide

* Avoid EUnit-enforced timeouts with prop_window_test_()
* Change folsom_sample_slide_test.erl to avoid failure like https://gist.github.com/272dc6bcd2478484bffa
* Fix sorting bug Russell sees but I don't, sorry!
  • Loading branch information...
commit 60106b919045b4de1d654cb1709cc18971826fca 1 parent dc0661a
Scott Lystig Fritchie authored January 02, 2013
4  test/folsom_sample_slide_test.erl
@@ -100,6 +100,6 @@ check_table(Slide, Moments) ->
100 100
     Tab = lists:sort(ets:tab2list(Slide#slide.reservoir)),
101 101
     {Ks, Vs} = lists:unzip(Tab),
102 102
     ExpectedVs = lists:sort(lists:flatten([lists:duplicate(10, N) || N <- Moments])),
103  
-    Keys = lists:usort(Ks),
104  
-    ?assertEqual(Moments, Keys),
  103
+    StrippedKeys = lists:usort([X || {X, _} <- Ks]),
  104
+    ?assertEqual(Moments, StrippedKeys),
105 105
     ?assertEqual(ExpectedVs, lists:sort(Vs)).
14  test/slide_statem_eqc.erl
@@ -36,7 +36,6 @@
36 36
 
37 37
 
38 38
 
39  
--define(NUMTESTS, 200).
40 39
 -define(QC_OUT(P),
41 40
         eqc:on_output(fun(Str, Args) ->
42 41
                               io:format(user, Str, Args) end, P)).
@@ -95,7 +94,8 @@ postcondition(#state{values=Values0, moment=Moment}, {call, ?MODULE, get_values,
95 94
     end;
96 95
 postcondition(#state{values=Values, sample=Sample, moment=Moment}, {call, ?MODULE, trim, _}, _TrimCnt) ->
97 96
     %% check that values and the actual table contents are the same after a trim
98  
-    Table = ets:tab2list(Sample#slide.reservoir),
  97
+    Table0 = ets:tab2list(Sample#slide.reservoir),
  98
+    Table = [{X, Y} || {{X, _}, Y} <- Table0],
99 99
     Model = lists:sort(trim(Values, Moment, ?WINDOW)),
100 100
     case Model == lists:sort(Table) of
101 101
         true ->
@@ -107,9 +107,13 @@ postcondition(_S, {call, ?MODULE, _, _}, _Res) ->
107 107
     true.
108 108
 
109 109
 prop_window_test_() ->
110  
-    {setup, fun() -> ok end, fun(_X) -> (catch meck:unload(folsom_utils)), folsom:stop() end,
111  
-     fun(_X) ->
112  
-                           ?_assert(eqc:quickcheck(eqc:numtests(?NUMTESTS, ?QC_OUT(prop_window())))) end}.
  110
+    Seconds = 10,
  111
+    {setup,
  112
+     fun() -> ok end,
  113
+     fun(_X) -> (catch meck:unload(folsom_utils)), folsom:stop() end,
  114
+     [{"QuickCheck Test",
  115
+       {timeout, Seconds*2, fun() -> true = eqc:quickcheck(eqc:testing_time(Seconds, ?QC_OUT(prop_window()))) end
  116
+       }}]}.
113 117
 
114 118
 prop_window() ->
115 119
     folsom:start(),

0 notes on commit 60106b9

Please sign in to comment.
Something went wrong with that request. Please try again.