Permalink
Browse files

bin/test.erl improvements, myapp removed (moved to ecomponents)

  • Loading branch information...
1 parent c0cab6e commit 42b573614a09c5cdf40e4e5671271364c09001d2 Michal Ptaszek committed Oct 19, 2009
View
@@ -49,10 +49,3 @@
debug_info,
strict_record_tests,
netload]}.
-
-{'lib/myapp-0.1/src/*', [
- {outdir, "lib/myapp-0.1/ebin"},
- {i, "lib/myapp-0.1/include"},
- debug_info,
- strict_record_tests,
- netload]}.
View
@@ -25,6 +25,8 @@
main([]) ->
run_tests("doc/ewts_report");
+main(["compile"]) ->
+ compile();
main(_) ->
print_usage().
@@ -40,8 +42,17 @@ start_interactive_mode_node(ReportDir) ->
[use_stdio, stderr_to_stdout, stream, {line, 1024}]),
print_output(Port).
+compile() ->
+ lists:foreach(fun(App) ->
+ FilesTest = filelib:wildcard(filename:join(["lib", App, "test", "*erl"])),
+ make:files(FilesTest, [{outdir, filename:join(["lib", App, "test"])},
+ {i, filename:join(["lib", App, "include"])}])
+ end, get_apps()).
+
print_output(Port) ->
receive
+ {Port, {data, {eol, "1> EWTSEND"}}} ->
+ port_close(Port);
{Port, {data, {eol, "1> " ++ Line}}} ->
io:format("~s~n", [Line]),
print_output(Port);
@@ -50,11 +61,50 @@ print_output(Port) ->
print_output(Port);
{Port, {data, _Data}} ->
print_output(Port)
- after 100000 ->
+ after 10000 ->
port_close(Port),
ok
end.
+get_apps() ->
+ filter(
+ element(2, file:list_dir("lib")), []).
+
+filter(["yaws" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["eptic" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["wpart-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["wparts-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["ewts-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["ewgi-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["kernel-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["stdlib-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["mnesia-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["inets-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["mochiweb-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["erlydtl-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["crypto-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["ssl-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter(["sasl-" ++ _ | Rest], Acc) ->
+ filter(Rest, Acc);
+filter([App | Rest], Acc) ->
+ filter(Rest, [App | Acc]);
+filter([], Acc) ->
+ Acc.
+
print_usage() ->
io:format("Usage:~n"
"bin/test.erl [run [ReportDir]] - run the tests~n"
@@ -3,16 +3,16 @@
-record(request, {
url :: string(),
cookies = [] :: string_proplist(),
- post_args = [] :: list({string(), string()}),
- get_args = [] :: list({string(), string()}),
+ post_args = [] :: string_proplist(),
+ get_args = [] :: string_proplist(),
protocol = http :: http | https
%% TODO - add multipart?
}).
-record(response, {
- headers :: list({string(), string()}),
+ headers :: string_proplist(),
code = 200 :: integer(),
- cookies :: list({string(), string()}),
+ cookies :: string_proplist(),
body = "" :: string(),
req_dict :: list()
}).
@@ -77,6 +77,7 @@ start_tests(Outdir) ->
true ->
io:format("EWTS: Wow! Hold your horses mighty cowboy - eunit has failed, hasn't it?~n")
end,
+ io:format("EWTSEND~n"),
init:stop().
-spec(fget/2 :: (string(), term()) -> undefined | term()).
No changes.
@@ -1,11 +0,0 @@
-%% -*- mode: erlang; -*-
-{application, myapp,
- [
- {description, ""},
- {vsn, "0.1"},
- {modules, [widget_tests, wtype_widget_test]},
- {registered, []},
- {applications, [kernel, stdlib, eptic, wpart, wparts, ewts]},
- {build_dependencies, []},
- {env, []}
- ]}.
@@ -1,49 +0,0 @@
--record(widget_test, {
- id,
- atom,
- autocomplete,
- bool,
- csv,
- date,
- datetime,
- enum,
- float,
- integer,
- multilist,
- password,
- string,
- text,
- time,
- upload}).
-
--record(widget_test_types, {
- id = {integer, [{primary_key},
- {private, true}]},
- atom = {atom, [{description, "Atom"}]},
- autocomplete = {autocomplete, [{description, "Autocomplete"},
- {complete, ["to","jest","test"]}]},
- bool = {bool, [{description, "Bool"},
- {always, ["man"]},
- {options, "man:Man|animal:Woman"}]},
- csv = {csv, [{description, "CSV"},
- {type, string},
- {delimiter, " "}]},
- date = {date, [{description, "Date"},
- {format, "YYYY-MM-DD"}]},
- datetime = {datetime, [{description, "Datetime"}]},
- enum = {enum, [{description, "Enum"},
- {chosen, "blue"},
- {choices, "blue:Blue|red:Red|none:I am color-blind"}]},
- float = {float, [{description, "Float"}]},
- integer = {integer, [{description, "Integer"}]},
- multilist = {multilist, [{description, "Multilist"},
- {options, "dog:Doggy|cat:Kitten|rhino:Other"},
- {selected, ["cat", "rhino"]},
- {html_attrs, [{multiple, "multiple"}]}]},
- password = {password, [{description, "Password"}]},
- string = {string, [{description, "String"},
- {html_attrs, [{class, required}]}]},
- text = {text, [{description, "Text"}]},
- time = {time, [{description, "Time"}]},
- upload = {upload, [{description, "Upload text file"},
- {extension, ".txt"}]}}).
@@ -1,15 +0,0 @@
-{static, "^/$", "index.html"}.
-{dynamic, "rss", {rss, blog}}.
-{dynamic, "^/blog/post/(?<post_no>[0-9]+)/comment/(?<comment_no>[0-9]+)/?$", {blog, comment}}.
-{static, "^/some_template\\.html$", "some_site.html"}.
-
-{static, "^/tpl_top_down", "top_down.html"}.
-
-{dynamic, "^/widgets/create", {widget_tests, render}}.
-{dynamic, "^/widgets/save", {widget_tests, save}}.
-{dynamic, "^/widgets/update/(?<id>[0-9]+)", {widget_tests, update_item}}.
-{dynamic, "^/widgets/update", {widget_tests, update}}.
-
-{static, "css$", enoent}.
-{static, "js$", enoent}.
-{static, "gif$", enoent}.
@@ -1,11 +0,0 @@
-<html>
-<head>
- <script type="text/javascript" src="/DateTimeShortcuts.js"> </script>
- <script type="text/javascript" src="/calendar.js"> </script>
-</head>
-<body>
- <h2>INDEX</h2>
-
- <wpart:date class="vDateField" />
-</body>
-</html>
@@ -1,7 +0,0 @@
-<html>
-<body>
- Parent template<br/>
- <wtpl:include name="child" />
- <wtpl:insert path="aaa.html" />
-</body>
-</html>
@@ -1,3 +0,0 @@
-<div>
- Inserted template
-</div>
@@ -1,9 +0,0 @@
-<wtpl:parent path="parent.html">
- <wtpl:content name="child">
-
- Child template
-
- <wtpl:insert path="some_slot.html" />
-
- </wtpl:content>
-</wtpl:parent>
@@ -1,18 +0,0 @@
-<html>
- <head>
- <link rel="stylesheet"
- href="/autocomplete.css"
- type="text/css" />
- <script src="/jquery.js"
- type="text/javascript"> </script>
- <script src="/jquery.autocomplete.js"
- type="text/javascript"> </script>
- </head>
- <body>
- <wpart:lookup key="error_message" />
- <wpart:form type="widget_test"
- wpart:action="/widgets/save?form_type={[string]get:form_type}"
- wpart:form_type="{[string]get:form_type}"
- submit_text="test widget"/>
- </body>
-</html>
@@ -1,18 +0,0 @@
-<html>
- <head>
- <link rel="stylesheet"
- href="/autocomplete.css"
- type="text/css" />
- <script src="/jquery.js"
- type="text/javascript"> </script>
- <script src="/jquery.autocomplete.js"
- type="text/javascript"> </script>
- </head>
- <body>
- <wpart:lookup key="error_message" />
- <wpart:form type="widget_test"
- wpart:action="/widgets/update?form_type={[string]get:form_type}"
- wpart:form_type="{[string]get:form_type}"
- submit_text="test widget"/>
- </body>
-</html>
@@ -1,60 +0,0 @@
--module(widget_tests).
-
--export([dataflow/1, error/2]).
--export([validate/2]).
--export([render/1, save/1, update_item/1, update/1]).
-
--spec(dataflow/1 :: (atom()) -> list() | tuple(list())).
-dataflow(save) -> [validate];
-dataflow(update) -> [validate];
-dataflow(_) -> [].
-
--spec(error/2 :: (atom(), term()) -> ok).
-error(Fun, _) when Fun == save; Fun == update ->
- Err = wpart:fget("__error"),
- Message = "ERROR: Incomplete input or wrong type in form! Reason: " ++ Err,
- wpart:fset("error_message", Message),
-
- NotValidated = wtype_widget_test:prepare_invalid(),
- wpart:fset("__edit", NotValidated),
-
- {template, "widget_test/" ++
- if
- Fun == save ->
- "create.html";
- true ->
- "update.html"
- end}.
-
-validate(save, _) ->
- validate_tool:validate_cu(widget_test, create);
-validate(update, _) ->
- validate_tool:validate_cu(widget_test, update).
-
-render(_) ->
- case wpart:fget("get:form_type") of
- undefined ->
- wpart:fset("get:form_type", "div");
- _ ->
- ok
- end,
- {template, "widget_test/create.html"}.
-
-save(Entity) ->
- wtype_widget_test:create(Entity),
-
- {redirect, "/"}.
-
-update_item([{id, Id}]) ->
- Item = e_db:read(widget_test, list_to_integer(Id)),
- Test = wpart_db:build_record_structure(widget_test, initial, Item),
-
- wpart:fset("__edit", Test),
- wpart:fset("__primary_key", list_to_integer(Id)),
-
- {template, "widget_test/update.html"}.
-
-update(Entity) ->
- wtype_widget_test:create(Entity),
-
- {redirect, "/"}.
@@ -1,27 +0,0 @@
--module(wtype_widget_test).
-
--export([get_record_info/1, install/0]).
--export([create/1]).
--export([prepare_invalid/0]).
-
--include_lib("myapp/include/widget_test.hrl").
-
--spec(get_record_info/1 :: (atom()) -> term()).
-get_record_info(widget_test) ->
- record_info(fields, widget_test);
-get_record_info(widget_test_types) ->
- #widget_test_types{}.
-
--spec(create/1 :: (tuple()) -> term()).
-create(Entity) ->
- e_db:write(widget_test, Entity).
-
--spec(prepare_invalid/0 :: () -> tuple()).
-prepare_invalid() ->
- wpart_db:build_record_structure(widget_test, initial,
- wpart:fget("__not_validated")).
-
--spec(install/0 :: () -> any()).
-install() ->
- mnesia:create_table(widget_test, [{attributes, get_record_info(widget_test)},
- {disc_copies, [node()]}]).
Oops, something went wrong.

0 comments on commit 42b5736

Please sign in to comment.