summaryrefslogtreecommitdiff
path: root/quickcheck
blob: 59da37191e9dc56b5e66fe238be47f509a1ad116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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, NumTestsStr, MaxSizeStr]) ->
    {ok, Hostname} = inet:gethostname(),
    Node = list_to_atom(NodeStr ++ "@" ++ Hostname),
    Mod  = list_to_atom(ModStr),
    NumTests = erlang:list_to_integer(NumTestsStr),
    MaxSize = erlang:list_to_integer(MaxSizeStr),
    case rpc:call(Node, code, ensure_loaded, [proper]) of
        {module, proper} ->
            case rpc:call(Node, proper, module,
                          [Mod] ++ [[{numtests,         NumTests},
                                     {max_size,         MaxSize},
                                     {constraint_tries, 200}]]) of
                [] -> ok;
                R  -> io:format("~p.~n", [R]),
                      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.