Browse Source

Skip dist tests unless stipulated or gen_leader present

If GPROC_DIST==false, dist tests are skipped
If GPROC_DIST==true, they are attempted
If GPROC_DIST not set, dist tests are run if gen_leader is found.
Ulf Wiger 11 years ago
parent
commit
b859ef3ba2
1 changed files with 28 additions and 8 deletions
  1. 28 8
      test/gproc_dist_tests.erl

+ 28 - 8
test/gproc_dist_tests.erl

@@ -25,18 +25,25 @@ dist_test_() ->
     {timeout, 120,
      [{setup,
        fun() ->
-	       Ns = start_slaves([dist_test_n1, dist_test_n2]),
-	       ?assertMatch({[ok,ok],[]},
-			    rpc:multicall(Ns, application, set_env,
-					  [gproc, gproc_dist, Ns])),
-	       ?assertMatch({[ok,ok],[]},
-			    rpc:multicall(Ns, application, start, [gproc])),
-	       Ns
+	       case run_dist_tests() of
+		   true ->
+		       Ns = start_slaves([dist_test_n1, dist_test_n2]),
+		       ?assertMatch({[ok,ok],[]},
+				    rpc:multicall(Ns, application, set_env,
+						  [gproc, gproc_dist, Ns])),
+		       ?assertMatch({[ok,ok],[]},
+				    rpc:multicall(
+				      Ns, application, start, [gproc])),
+		       Ns;
+		   false ->
+		       skip
+	       end
        end,
        fun(_Ns) ->
 	       ok
        end,
-       fun(Ns) ->
+       fun(skip) -> [];
+	  (Ns) when is_list(Ns) ->
 	       {inorder,
 		[
 		 {inparallel, [
@@ -94,6 +101,19 @@ dist_test_() ->
        end
       }]}.
 
+run_dist_tests() ->
+    case os:getenv("GPROC_DIST") of
+	"true" -> true;
+	"false" -> false;
+	false ->
+	    case code:ensure_loaded(gen_leader) of
+		{error, nofile} ->
+		    false;
+		_ ->
+		    true
+	    end
+    end.
+
 -define(T_NAME, {n, g, {?MODULE, ?LINE}}).
 -define(T_KVL, [{foo, "foo"}, {bar, "bar"}]).
 -define(T_COUNTER, {c, g, {?MODULE, ?LINE}}).