Skip to content
Browse files

First sketch of bin/test.erl implemented

  • Loading branch information...
1 parent 71dba51 commit 8280984becb9228795a8818c216ab041ac2a0a1b Michal Ptaszek committed Oct 13, 2009
Showing with 60 additions and 8 deletions.
  1. +52 −0 bin/test.erl
  2. +8 −8 lib/ewts-1.0/src/ewts.erl
View
52 bin/test.erl
@@ -0,0 +1,52 @@
+#!/usr/bin/env escript
+
+%% The contents of this file are subject to the Erlang Web Public License,
+%% Version 1.0, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Web Public License along with this software. If not, it can be
+%% retrieved via the world wide web at http://www.erlang-consulting.com/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Initial Developer of the Original Code is Erlang Training & Consulting
+%% Ltd. Portions created by Erlang Training & Consulting Ltd are Copyright 2009,
+%% Erlang Training & Consulting Ltd. All Rights Reserved.
+
+%%-------------------------------------------------------------------
+%%% File : test.erl
+%%% Author : Michal Ptaszek <michal.ptaszek@erlang-consulting.com>
+%%% Description : Escript interface for EWTS application.
+%%%
+%%% Created : 13 Oct 2009 by michalptaszek <michalptaszek@coltrane.erlangsystems.com>
+%%%-------------------------------------------------------------------
+
+main([]) ->
+ run_tests("ewts_reports");
+main(_) ->
+ print_usage().
+
+run_tests() ->
+ start_interactive_mode_node().
+
+start_interactive_mode_node(ReportDir) ->
+ Port = open_port({spawn, "bin/start_interactive -run ewts start_tests" ++ ReportDir},
+ [use_stdio, stderr_to_stdout, stream, {line, 1024}]),
+ print_output(Port).
+
+print_output(Port) ->
+ receive
+ {Port, {data, {eol, "EWTS: " ++ Line}}} ->
+ io:format(Line);
+ {Port, {data, _Data}} ->
+ print_output(Port)
+ after 1000 ->
+ ok
+ end.
+
+print_usage() ->
+ io:format("Usage:~n"
+ "bin/test.erl [run] - run the tests~n"
+ "bin/test.erl compile - compile the tests - do not run them~n").
View
16 lib/ewts-1.0/src/ewts.erl
@@ -7,8 +7,8 @@ start_tests(Outdir) ->
error_logger:tty(false),
Modules = lists:concat(lists:map(
fun(Application) ->
- Result = cover:compile_directory(filename:join(["../../apps/", Application, "src"]),
- [{i, filename:join(["/../../apps/", Application, "include"])}]),
+ Result = cover:compile_directory(filename:join(["../../", Application, "src"]),
+ [{i, filename:join(["../../", Application, "include"])}]),
if
is_list(Result) ->
lists:foldl(fun({ok, M}, Acc) -> [M | Acc];
@@ -18,13 +18,13 @@ start_tests(Outdir) ->
end
end, get_apps())),
TestModules = [list_to_atom(filename:basename(F, ".erl")) ||
- F <- filelib:wildcard(filename:join("../../apps/*/test/", "*.erl"))],
+ F <- filelib:wildcard("../../*/test/*.erl")],
EUnitResult = eunit:test(TestModules),
if
EUnitResult == ok ->
TotalPercentage = html_report(Outdir, Modules),
- io:format("All tests passed. ~B% line coverage.~n", [TotalPercentage]),
+ io:format("EWTS: All tests passed. ~B% line coverage.~n", [TotalPercentage]),
%% Taken from http://idlingspace.com/game/perfect_lemmings/lemmingology_mathe/
Needed = 70,
@@ -49,9 +49,9 @@ start_tests(Outdir) ->
Rescued == 100 ->
"Superb! You rescued every lemming on that level. Can you do it again....?"
end,
- io:format("~s~n", [Msg]);
+ io:format("EWTS: ~s~n", [Msg]);
true ->
- io:format("Wow! Hold your horses mighty cowboy - eunit has failed, hasn't it?~n")
+ io:format("EWTS: Wow! Hold your horses mighty cowboy - eunit has failed, hasn't it?~n")
end,
init:stop().
@@ -88,8 +88,8 @@ fget0(List, Key, Dict) ->
-spec(get_apps/0 :: () -> (list(string()))).
get_apps() ->
- element(2, file:list_dir("../../apps/")) -- ["yaws", "eptic", "eptic_fe", "wpart",
- "wparts", "ewts"].
+ element(2, file:list_dir("../../")) -- ["yaws", "eptic", "eptic_fe", "wpart",
+ "wparts", "ewts"].
html_report(Path, Modules) ->
Results = lists:map(fun(Module) ->

0 comments on commit 8280984

Please sign in to comment.
Something went wrong with that request. Please try again.