quickcheck
author Simon MacMullen <simon@rabbitmq.com>
Fri Feb 03 15:59:12 2012 +0000 (3 months ago)
changeset 8922 4f87837a40be
parent 7515 8be9c1a4d172
permissions -rwxr-xr-x
Merge bug24702
     1 #!/usr/bin/env escript
     2 %% -*- erlang -*-
     3 %%! -sname quickcheck
     4 -mode(compile).
     5 
     6 %% A helper to test quickcheck properties on a running broker
     7 %% NodeStr is a local broker node name
     8 %% ModStr is the module containing quickcheck properties
     9 %% TrialsStr is the number of trials
    10 main([NodeStr, ModStr, TrialsStr]) ->
    11     {ok, Hostname} = inet:gethostname(),
    12     Node = list_to_atom(NodeStr ++ "@" ++ Hostname),
    13     Mod  = list_to_atom(ModStr),
    14     Trials = erlang:list_to_integer(TrialsStr),
    15     case rpc:call(Node, code, ensure_loaded, [proper]) of
    16         {module, proper} ->
    17             case rpc:call(Node, proper, module,
    18                           [Mod] ++ [[{numtests, Trials}, {constraint_tries, 200}]]) of
    19                 [] -> ok;
    20                 _  -> quit(1)
    21             end;
    22         {badrpc, Reason} ->
    23             io:format("Could not contact node ~p: ~p.~n", [Node, Reason]),
    24             quit(2);
    25         {error,nofile} ->
    26             io:format("Module PropEr was not found on node ~p~n", [Node]),
    27             quit(2)
    28     end;
    29 main([]) ->
    30     io:format("This script requires a node name and a module.~n").
    31 
    32 quit(Status) ->
    33     case os:type() of
    34         {unix,  _} -> halt(Status);
    35         {win32, _} -> init:stop(Status)
    36     end.
    37