- Timestamp:
- 01/28/10 16:21:51 (2 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
doc/TODO (modified) (1 diff)
-
install (modified) (1 diff)
-
src/modules.erl (modified) (3 diffs)
-
src/modules_test.erl (modified) (2 diffs)
-
src/tester.erl (modified) (5 diffs)
-
src/tester_test.erl (modified) (8 diffs)
-
src/text_printer.erl (modified) (1 diff)
-
src/text_printer_test.erl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/TODO
r88 r92 7 7 ----------------------- 8 8 9 - does a removed source file get removed from tester? 10 9 11 Features? 10 12 --------- 11 13 12 - add a "run once" mode for directory_tester13 - print file(line) for test errors too14 - remove or print to text =ERROR REPORT==== from tests which15 voluntarily crash processes16 14 - detect -include dependencies and recompile all when .hrl changes 15 - allow giving additional include directories (for 3rd party libraries) 17 16 - run tests in parallel 18 17 - run a single (specific) test -
trunk/install
r90 r92 6 6 cd ebin 7 7 erl -make 8 erl -sname extremeforge_install_tester -noinput &8 erl -sname extremeforge_install_tester@$hostname -noinput & 9 9 erl -kernel error_logger "{file,\"../install_errors.log\"}" \ 10 -sname extremeforge_installer \10 -sname extremeforge_installer@$hostname \ 11 11 -noinput \ 12 12 -run directory_tester run_once ".." extremeforge_install_tester@$hostname \ -
trunk/src/modules.erl
r68 r92 9 9 -export ([compile/1]). 10 10 -export ([module_name/1]). 11 -export ([locate/2]). 11 12 12 13 to_binary (File_name) -> … … 23 24 24 25 compile (Fun, Parameter) -> 25 Options = [binary, return, warn_unused_import ],26 Options = [binary, return, warn_unused_import, debug_info], 26 27 Fun (Parameter, Options). 27 28 … … 33 34 String = filename: rootname (filename: basename (Filename)), 34 35 list_to_atom (String). 36 37 locate ({M, F, A}, Binary) -> 38 {ok, {M, Chunks}} = beam_lib: chunks (Binary, [abstract_code, compile_info]), 39 [{abstract_code, Code}, {compile_info, Info}] = Chunks, 40 {value, {source, Filename}} = lists: keysearch (source, 1, Info), 41 {raw_abstract_v1, Forms} = Code, 42 Line = locate_line (F, A, Forms), 43 {Filename, Line}. 44 45 locate_line (Function, Arity, [{function, Line, Function, Arity, _} | _]) -> 46 Line; 47 locate_line (Function, Arity, [_ | Forms]) -> 48 locate_line (Function, Arity, Forms); 49 locate_line (_, _, []) -> 50 unknown. -
trunk/src/modules_test.erl
r68 r92 6 6 -test (exports). 7 7 -export ([module_name/0]). 8 -export ([locate/0]). 8 9 9 10 module_name () -> … … 11 12 hello = modules: module_name ("bla/hello.erl"). 12 13 14 locate () -> 15 ok = fixtures: use_tree (tree (), fun locate/2). 16 17 tree () -> 18 [{file, "eg_code.erl", 19 ["-module (eg_code).", 20 "-export ([ok/0]).", 21 "ok () ->", 22 " ok.", 23 "yo () ->", 24 " yo."]}]. 25 26 locate (Root, _) -> 27 File = filename: join (Root, "eg_code.erl"), 28 Binary = modules: to_binary (File), 29 {File, 3} = modules: locate ({eg_code, ok, 0}, Binary), 30 ok. -
trunk/src/tester.erl
r90 r92 10 10 With_notify = dict: store (notify, Notify, dict: new ()), 11 11 With_tests = dict: store (tests, dict: new (), With_notify), 12 State = dict: store (node, Node, With_tests), 12 With_binaries = dict: store (binaries, dict: new (), With_tests), 13 State = dict: store (node, Node, With_binaries), 13 14 loop (State). 14 15 … … 34 35 Test_dict = dict: fetch (tests, State), 35 36 New_tests = dict: store (Module, Time_stamped_tests, Test_dict), 36 dict: store (tests, New_tests, State). 37 Binaries_dict = dict: fetch (binaries, State), 38 New_binaries = dict: store (Module, Binary, Binaries_dict), 39 dict: store (binaries, New_binaries, dict: store (tests, New_tests, State)). 37 40 38 41 test (State) -> … … 75 78 Tests = dict: fetch (tests, State), 76 79 New_tests = dict: erase (Module, Tests), 77 dict :store (tests, New_tests, State). 80 Binaries = dict: fetch (binaries, State), 81 New_binaries = dict: erase (Module, Binaries), 82 dict: store (binaries, New_binaries, dict :store (tests, New_tests, State)). 78 83 79 84 flatten (Tests) -> … … 104 109 Node = dict: fetch (node, State), 105 110 Notify = dict: fetch (notify, State), 111 Binaries = dict: fetch (binaries, State), 106 112 fun (Test_definition, {Tester_state, {Run, Passed}}) -> 107 113 {Module, Function, Stamp} = Test_definition, … … 111 117 {'EXIT', Pid, normal} -> 112 118 {Passed + 1, first_test_success (Stamp, now())}; 113 {'EXIT', Pid, Reason} -> 119 {'EXIT', Pid, {Error, Stack_trace}} -> 120 Binary = dict: fetch (Module, Binaries), 121 MFA = {Module, Function, 0}, 122 {File, Line} = modules: locate (MFA, Binary), 123 Location = {Module, Function, 0, File, Line}, 124 List = [{error, Error}, 125 {stack_trace, Stack_trace}, 126 {location, Location}], 127 Reason = dict: from_list (List), 114 128 Notify (Reason), 115 129 {Passed, failed} -
trunk/src/tester_test.erl
r91 r92 17 17 18 18 run_all (Node) -> 19 20 19 Fun = run_fun (Node), 21 20 ok = fixtures: use_tree (tree (), Fun). … … 31 30 deletes_a_test_module (Node, Root), 32 31 runs_new_tests_failed_then_successful (Node, Root), 32 provides_failed_test_and_location (Node, Root), 33 33 stops (Node, Root), 34 34 ok … … 38 38 Paths = [modules: to_file_name (M, Root) || M <- Modules], 39 39 Binaries = [modules: to_binary (P) || P <- Paths], 40 %false = lists: any (fun (M) -> code: is_loaded (M) end, Modules),40 false = lists: any (fun (M) -> code: is_loaded (M) end, Modules), 41 41 Tester ! {run, Binaries}, 42 42 Results = receive_all ([]), 43 %false = lists: any (fun (M) -> code: is_loaded (M) end, Modules),43 false = lists: any (fun (M) -> code: is_loaded (M) end, Modules), 44 44 Results. 45 45 … … 51 51 Tester = spawn_link (tester, init, [notify_me (), Node]), 52 52 [{2, 0, 0}, {2, 1, 1}, Error, {2, 2, 1}] = send (Root, [eg_test], Tester), 53 {{badmatch, nok}, [{eg_test, nok, 0} | _]} = Error, 53 {badmatch, nok} = dict: fetch (error, Error), 54 [{eg_test, nok, 0} | _] = dict: fetch (stack_trace, Error), 54 55 ok. 55 56 … … 57 58 Tester = spawn_link (tester, init, [notify_me (), Node]), 58 59 [{1, 0, 0}, Error, {1, 1, 0}] = send (Root, [eg_test_of_code], Tester), 59 {undef, [{eg_code, ok, []}, {eg_test_of_code, ok, 0} | _]} = Error, 60 undef = dict: fetch (error, Error), 61 Stack_trace = dict: fetch (stack_trace, Error), 62 [{eg_code, ok, []}, {eg_test_of_code, ok, 0} | _] = Stack_trace, 60 63 [{1, 0, 0}, {1, 1, 1}] = send (Root, [eg_code], Tester), 61 64 ok. … … 80 83 Binary = modules: forms_to_binary (eg_test_form ("nok")), 81 84 Tester ! {run, [Binary]}, 82 Results = receive_all ([]), 83 [{1, 0, 0}, _Error, {1, 1, 0}] = Results, 85 [{1, 0, 0}, Error, {1, 1, 0}] = receive_all ([]), 84 86 Correct_binary = modules: forms_to_binary (eg_test_form ("ok")), 85 87 Tester ! {run, [Correct_binary]}, 86 88 [{1, 0, 0}, {1, 1, 1}] = receive_all ([]), 87 89 Tester ! {run, [Binary]}, 88 [{1, 0, 0}, _Error, {1, 1, 0}] = receive_all ([]),90 [{1, 0, 0}, Error, {1, 1, 0}] = receive_all ([]), 89 91 ok. 90 92 … … 94 96 Tester ! {delete,[eg_code]}, 95 97 [{1, 0, 0}, Error, {1, 1, 0}] = receive_all ([]), 96 {undef, [{eg_code, ok, []}, {eg_test_of_code, ok, 0} | _]} = Error, 98 undef = dict: fetch (error, Error), 99 [{eg_code, ok, []} | _] = dict: fetch (stack_trace, Error), 97 100 [{1, 0, 0}, {1, 1, 1}] = send (Root, [eg_code], Tester), 98 101 ok. … … 111 114 Result = send (Root, Modules, Tester), 112 115 [{1, 0, 0}, Error, {1, 1, 0}] = Result, 113 {{badmatch, bad_eg_code}, _} = Error, 114 116 {badmatch, bad_eg_code} = dict: fetch (error, Error), 115 117 Result_after_new_test = send (Root, [eg_test_not_exports], Tester), 116 118 [{2, 0, 0}, {2, 1, 1}, Error, {2, 2, 1}] = Result_after_new_test, 117 118 119 New_run = send (Root, [eg_test_of_code], Tester), 119 120 [{3, 0, 0}, {3, 1, 1}, Error, {3, 2, 1}, {3, 3, 2}] = New_run, 121 ok. 122 123 provides_failed_test_and_location (Node, Root) -> 124 Tester = spawn_link (tester, init, [notify_me (), Node]), 125 [{2, 0, 0}, {2, 1, 1}, Error, {2, 2, 1}] = send (Root, [eg_test], Tester), 126 Filename = filename: join (Root, "eg_test.erl"), 127 {eg_test, nok, 0, Filename, 6} = dict: fetch (location, Error), 120 128 ok. 121 129 -
trunk/src/text_printer.erl
r87 r92 43 43 testing (Device); 44 44 {_, tester, Other} -> 45 Line = io_lib: fwrite ("~nError: ~p.\n", [Other]), 46 io: put_chars (Device, Line), 45 Error = dict: fetch (error, Other), 46 Stack = dict: fetch (stack_trace, Other), 47 {M, F, A, File, Line} = dict: fetch (location, Other), 48 Output = io_lib: fwrite ( 49 "~n~s(~p): failure in {~p, ~p, ~p}~n" 50 " Error: ~p~n" 51 " Stack: ~p~n", [File, Line, M, F, A, Error, Stack]), 52 io: put_chars (Device, Output), 47 53 testing (Device) 48 54 end. -
trunk/src/text_printer_test.erl
r87 r92 39 39 P ! {self (), tester, {4, 2, 2}}, 40 40 <<".">> = receive_io_request (P), 41 P ! {self (), tester, {undef, [{foo, bar, []}, {toto, titi, 0}]}}, 42 <<"\nError: {undef,[{foo,bar,[]},{toto,titi,0}]}.\n">> = receive_io_request (P), 41 Error = {error, {undef, [{foo, bar, []}, {toto, titi, 0}]}}, 42 Stack = {stack_trace, [{eg_test, ok, 0}, {test_runner, run, 0}]}, 43 Locat = {location, {eg_test, ok, 0, "/dir/eg_test.erl", 12}}, 44 Dict = dict: from_list ([Error, Stack, Locat]), 45 P ! {self (), tester, Dict}, 46 <<"\n/dir/eg_test.erl(12): failure in {eg_test, ok, 0}" 47 "\n Error: {undef,[{foo,bar,[]},{toto,titi,0}]}" 48 "\n Stack: [{eg_test,ok,0},{test_runner,run,0}]\n">> = receive_io_request (P), 43 49 P ! {self (), tester, {4, 3, 2}}, 44 50 <<".">> = receive_io_request (P), … … 66 72 Self = self (), 67 73 receive 68 {io_request, P, Self, {put_chars, Binary}} ->74 {io_request, P, Self, {put_chars, unicode, Binary}} -> 69 75 P ! {io_reply, Self, ok}, 70 76 Binary;
Note: See TracChangeset
for help on using the changeset viewer.
