2011-06-28 21:00:29 +08:00
|
|
|
#!/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
|
2011-10-24 18:39:40 +08:00
|
|
|
%% TrialsStr is the number of trials
|
2014-06-26 22:16:55 +08:00
|
|
|
main([NodeStr, ModStr, NumTestsStr, MaxSizeStr]) ->
|
2011-07-01 23:08:19 +08:00
|
|
|
{ok, Hostname} = inet:gethostname(),
|
|
|
|
|
Node = list_to_atom(NodeStr ++ "@" ++ Hostname),
|
|
|
|
|
Mod = list_to_atom(ModStr),
|
2014-06-26 22:16:55 +08:00
|
|
|
NumTests = erlang:list_to_integer(NumTestsStr),
|
|
|
|
|
MaxSize = erlang:list_to_integer(MaxSizeStr),
|
2011-06-28 21:00:29 +08:00
|
|
|
case rpc:call(Node, code, ensure_loaded, [proper]) of
|
|
|
|
|
{module, proper} ->
|
2011-10-24 18:39:40 +08:00
|
|
|
case rpc:call(Node, proper, module,
|
2014-06-26 22:16:55 +08:00
|
|
|
[Mod] ++ [[{numtests, NumTests},
|
|
|
|
|
{max_size, MaxSize},
|
2014-06-02 20:01:58 +08:00
|
|
|
{constraint_tries, 200}]]) of
|
2011-06-28 21:00:29 +08:00
|
|
|
[] -> ok;
|
2014-05-28 18:06:54 +08:00
|
|
|
R -> io:format("~p.~n", [R]),
|
|
|
|
|
quit(1)
|
2011-06-28 21:00:29 +08:00
|
|
|
end;
|
2011-07-01 23:08:19 +08:00
|
|
|
{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]),
|
2011-06-28 21:00:29 +08:00
|
|
|
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.
|
|
|
|
|
|