rabbitmq-server/quickcheck

38 lines
1.2 KiB
Erlang
Executable File

#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname quickcheck
-mode(compile).
%% A helper to test quickcheck properties on a running broker
%% NodeStr is a local broker node name
%% ModStr is the module containing quickcheck properties
%% TrialsStr is the number of trials
main([NodeStr, ModStr, TrialsStr]) ->
{ok, Hostname} = inet:gethostname(),
Node = list_to_atom(NodeStr ++ "@" ++ Hostname),
Mod = list_to_atom(ModStr),
Trials = erlang:list_to_integer(TrialsStr),
case rpc:call(Node, code, ensure_loaded, [proper]) of
{module, proper} ->
case rpc:call(Node, proper, module,
[Mod] ++ [[{numtests, Trials}, {constraint_tries, 200}]]) of
[] -> ok;
_ -> quit(1)
end;
{badrpc, Reason} ->
io:format("Could not contact node ~p: ~p.~n", [Node, Reason]),
quit(2);
{error,nofile} ->
io:format("Module PropEr was not found on node ~p~n", [Node]),
quit(2)
end;
main([]) ->
io:format("This script requires a node name and a module.~n").
quit(Status) ->
case os:type() of
{unix, _} -> halt(Status);
{win32, _} -> init:stop(Status)
end.