PageRenderTime 102ms CodeModel.GetById 61ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/ucengine/src/core/tests.erl

http://github.com/AF83/ucengine
Erlang | 62 lines | 41 code | 4 blank | 17 comment | 0 complexity | ad3a8c65950d9e57cb9ff025d390c0e1 MD5 | raw file
 1%%
 2%%  U.C.Engine - Unified Collaboration Engine
 3%%  Copyright (C) 2011 af83
 4%%
 5%%  This program is free software: you can redistribute it and/or modify
 6%%  it under the terms of the GNU Affero General Public License as published by
 7%%  the Free Software Foundation, either version 3 of the License, or
 8%%  (at your option) any later version.
 9%%
10%%  This program is distributed in the hope that it will be useful,
11%%  but WITHOUT ANY WARRANTY; without even the implied warranty of
12%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13%%  GNU Affero General Public License for more details.
14%%
15%%  You should have received a copy of the GNU Affero General Public License
16%%  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17%%
18-module(tests).
19
20-include("uce.hrl").
21
22-export([run/0, start/0]).
23
24start() ->
25    case run() of
26        error ->
27            init:stop(2);
28        ok ->
29            init:stop(0)
30    end.
31
32run() ->
33    Modules = [event_tests,
34               search_tests,
35               meeting_tests,
36               presence_tests,
37               user_tests,
38               file_tests,
39               role_tests,
40               ctl_tests,
41               url_tests] ++
42        case config:get(search) of
43            solr ->
44                [solr_tests];
45            _ ->
46                []
47        end,
48    Failed = lists:filter(fun(Module) ->
49                                  io:format("> ~p~n", [Module]),
50                                  case Module:test() of
51                                      ok ->
52                                          false;
53                                      error ->
54                                          true
55                                  end
56                          end, Modules),
57    if
58        length(Failed) > 0 ->
59            error;
60        true ->
61            ok
62    end.