Changeset 73


Ignore:
Timestamp:
07/15/09 10:00:25 (3 years ago)
Author:
dom
Message:

Refactoring.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shells_tests.erl

    r68 r73  
    2424    Paths = [modules: to_file_name (M, "../src") || M <- Modules], 
    2525    Binaries = [modules: to_binary (P) || P <- Paths], 
    26     Tester ! lists: zip (Paths, Binaries), 
     26    Tester ! {run, Binaries}, 
    2727    {Run, Passed, Messages} = final_test_result ([]), 
    2828    {passed, Run, Paths, Messages} = {passed, Passed, Paths, Messages}, 
  • trunk/src/tester.erl

    r44 r73  
    2323        {runner_end, New_state} -> 
    2424            loop (New_state); 
    25         Modules -> 
     25        {run, Modules} -> 
    2626            loop (test (load (Modules, State))) 
    2727    end. 
     
    3030    lists: foldl (fun load_aux/2, State, Modules). 
    3131 
    32 load_aux ({File_name, Binary}, State) -> 
    33     {Module, Tests} = tests: filter_by_attribute (Binary), 
     32load_aux (Binary, State) -> 
     33    {File_name, Module, Tests} = tests: filter_by_attribute (Binary), 
    3434    Node = dict: fetch (node, State), 
    3535    Load_args = [Module, File_name, Binary], 
  • trunk/src/tester_test.erl

    r45 r73  
    2222    Binaries = [modules: to_binary (P) || P <- Paths], 
    2323    false = lists: any (fun (M) -> code: is_loaded (M) end, Modules), 
    24     Tester ! lists: zip (Paths, Binaries), 
     24    Tester ! {run, Binaries}, 
    2525    Results = receive_all ([]), 
    2626    false = lists: any (fun (M) -> code: is_loaded (M) end, Modules), 
     
    6262    Tester = spawn_link (tester, init, [notify_me (), Node]), 
    6363    Binary = modules: forms_to_binary (eg_test_form ("nok")), 
    64     Tester ! [{"./eg_test.erl", Binary}], 
     64    Tester ! {run, [Binary]}, 
    6565    Results = receive_all ([]), 
    6666    [{1, 0, 0}, _Error, {1, 1, 0}] = Results, 
    6767    Correct_binary = modules: forms_to_binary (eg_test_form ("ok")), 
    68     Tester ! [{"./eg_test.erl", Correct_binary}], 
     68    Tester ! {run, [Correct_binary]}, 
    6969    [{1, 0, 0}, {1, 1, 1}] = receive_all ([]), 
    70     Tester ! [{"./eg_test.erl", Binary}], 
     70    Tester ! {run, [Binary]}, 
    7171    [{1, 0, 0}, _Error, {1, 1, 0}] = receive_all ([]), 
    7272    ok. 
  • trunk/src/tests.erl

    r72 r73  
    77 
    88filter_by_attribute (Binary) -> 
    9     {ok, Chunks} = beam_lib: chunks (Binary, [attributes]), 
    10     {Module, [{attributes, Attributes}]} = Chunks, 
     9    {ok, Chunks} = beam_lib: chunks (Binary, [attributes, compile_info]), 
     10    {Module, [{attributes, Attributes}, {compile_info, Info}]} = Chunks, 
     11    {value, {source, Filename}} = lists: keysearch (source, 1, Info), 
    1112    Declarations = lists: flatten ([T || {test, T} <- Attributes]), 
    1213    Tests = filter (Binary, Declarations, []), 
    13     {Module, Tests}. 
     14    {Filename, Module, Tests}. 
    1415 
    1516filter (Binary, [exports | Tail], Acc) -> 
  • trunk/src/tests_test.erl

    r35 r73  
    1515non_tests_returns_empty_list () -> 
    1616    Binary = modules: to_binary ("../fix/eg_code.erl"), 
    17     {eg_code, []} = tests: filter_by_attribute (Binary). 
     17    {_, eg_code, []} = tests: filter_by_attribute (Binary). 
    1818 
    1919test_exports_returns_list_of_tests_from_unloaded_binary () -> 
     
    2121    Binary = modules: to_binary (File), 
    2222    false = code: is_loaded (eg_test), 
    23     {eg_test, [ok, nok]} = tests: filter_by_attribute (Binary), 
     23    {_, eg_test, [ok, nok]} = tests: filter_by_attribute (Binary), 
    2424    false = code: is_loaded (eg_test). 
    2525 
     
    2828    Binary = modules: to_binary (File), 
    2929    false = code: is_loaded (eg_test_not_exports), 
    30     {eg_test_not_exports, [ok]} = tests: filter_by_attribute (Binary), 
     30    {_, eg_test_not_exports, [ok]} = tests: filter_by_attribute (Binary), 
    3131    false = code: is_loaded (eg_test_not_exports). 
Note: See TracChangeset for help on using the changeset viewer.