Changeset 34 for trunk


Ignore:
Timestamp:
08/22/08 18:46:07 (4 years ago)
Author:
dom
Message:

Removed everything related to fixtures while the concept matures a bit.

Location:
trunk
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shells.erl

    r33 r34  
    2828    ok = tester_test: reruns_a_test_when_given_module (Test_node), 
    2929    ok = tester_test: runs_given_tests (Test_node), 
    30     ok = tester_test: runs_a_fixtured_test (Test_node), 
    3130    Caller ! {Caller, done}. 
    3231     
  • trunk/src/tester.erl

    r30 r34  
    2222 
    2323load ({File_name, Binary}, State) -> 
    24     {Module, Functions} = tests: filter_by_attribute (Binary), 
     24    {Module, Tests} = tests: filter_by_attribute (Binary), 
    2525    Node = dict: fetch (node, State), 
    2626    Load_args = [Module, File_name, Binary], 
    2727    {module, Module} = rpc: call (Node, code, load_binary, Load_args), 
    28     New_tests = dict: store (Module, Functions, dict: fetch (tests, State)), 
     28    New_tests = dict: store (Module, Tests, dict: fetch (tests, State)), 
    2929    dict: store (tests, New_tests, State). 
    3030 
    3131test (State) -> 
    32     {Total, Tests} = flatten (dict: fetch (tests, State)), 
     32    Test_dict = dict: fetch (tests, State), 
     33    {Total, Tests} = flatten (Test_dict), 
    3334    Notify = dict: fetch (notify, State), 
    3435    Notify ({Total, 0, 0}), 
     
    3738 
    3839flatten (Tests) -> 
    39     F = fun (_, Ts, {Count, List}) -> 
    40                 {Count + length (Ts), [Ts | List]} 
     40    F = fun (Module, Ts, {Count, List}) -> 
     41                {Count + length (Ts), [[{Module, T} || T <- Ts] | List]} 
    4142        end, 
    4243    {Total, All} = dict: fold (F, {0, []}, Tests), 
     
    4647    Node = dict: fetch (node, State), 
    4748    Notify = dict: fetch (notify, State), 
    48     fun ({M, F, A}, {Run, Passed}) -> 
    49             Pid = spawn_link (Node, M, F, A), 
     49    fun ({Module, Function}, {Run, Passed}) -> 
     50            Pid = spawn_link (Node, Module, Function, []), 
    5051            New_passed = 
    5152                receive 
  • trunk/src/tester_test.erl

    r33 r34  
    66-export ([runs_a_test/1, reruns_a_test_when_given_module/1]). 
    77-export ([runs_given_tests/1]). 
    8 -export ([runs_a_fixtured_test/1]). 
    9 -test ([{nodes_fix, test_node, [runs_a_test, runs_given_tests]}]). 
    10 -test ([{nodes_fix, test_node, [reruns_a_test_when_given_module]}]). 
    118 
    129start_tester (Node) -> 
     
    4643    ok. 
    4744 
    48 runs_a_fixtured_test (Node) -> 
    49     Tester = start_tester (Node), 
    50     [{1, 0, 0}, {1, 1, 1}] = send (eg_test_fix, Tester), 
    51     ok. 
    52  
    5345receive_all (Ms) -> 
    5446    receive 
  • trunk/src/tests.erl

    r33 r34  
    1010    {Module, [{attributes, Attributes}]} = Chunks, 
    1111    Declarations = lists: flatten ([T || {test, T} <- Attributes]), 
    12     filter_by_attribute (Module, Binary, Declarations, []). 
     12    Tests = filter (Binary, Declarations, []), 
     13    {Module, Tests}. 
     14 
     15filter (Binary, [exports | Tail], Acc) -> 
     16    {ok, Chunks} = beam_lib: chunks (Binary, [exports]), 
     17    {_, [{exports, Exports}]} = Chunks, 
     18    Tests = lists: foldl (fun testable_export/2, [], Exports), 
     19    filter (Binary, Tail, [Tests | Acc]); 
     20filter (_, [], Acc) -> 
     21    lists: flatten (Acc). 
     22 
     23testable_export ({module_info, _}, Fs) -> Fs; 
     24testable_export ({F, 0}, Fs) -> [F | Fs]; 
     25testable_export (_, Fs) -> Fs. 
    1326 
    1427receive_all () -> 
    1528    receive_all ([]). 
    16  
    17 filter_by_attribute (Module, Binary, [exports | Tail], Tests) -> 
    18     {ok, Chunks} = beam_lib: chunks (Binary, [exports]), 
    19     {Module, [{exports, Exports}]} = Chunks, 
    20     Funs = exports_to_funs (Module, Exports, []), 
    21     filter_by_attribute (Module, Binary, Tail, [Funs | Tests]); 
    22 filter_by_attribute (Module, Binary, [{M, F, Ts} | Tail], Tests) -> 
    23     Funs = [{Module, T} || T <- Ts], 
    24     filter_by_attribute (Module, Binary, Tail, [{M, F, [Funs]} | Tests]); 
    25 filter_by_attribute (Module, _, [], Tests) -> 
    26     {Module, lists: flatten (Tests)}. 
    27  
    28 exports_to_funs (M, [{module_info, _} | Exports], Funs) -> 
    29     exports_to_funs (M, Exports, Funs); 
    30 exports_to_funs (M, [{F, 0} | Exports], Funs) -> 
    31     exports_to_funs (M, Exports, [{M, F, []} | Funs]); 
    32 exports_to_funs (M, [{_, _} | Exports], Funs) -> 
    33     exports_to_funs (M, Exports, Funs); 
    34 exports_to_funs (_, [], Funs) -> 
    35     Funs. 
    3629 
    3730receive_all (Ms) -> 
  • trunk/src/tests_test.erl

    r33 r34  
    99filter_by_attribute () -> 
    1010    filtering_non_tests_returns_empty_list(), 
    11     filtering_tests_returns_list_of_MFA_from_unloaded_binary (), 
    12     filtering_fixtured_tests_returns_list_of_fixture_fun_tuples (), 
    13     filtering_understands_mixed_export_and_fixtured_tests (), 
     11    filtering_tests_returns_list_of_tests_from_unloaded_binary (), 
    1412    ok. 
    1513 
    1614filtering_non_tests_returns_empty_list () -> 
    17     Binary = modules: to_binary ("../fix/eg_code.erl"),  
     15    Binary = modules: to_binary ("../fix/eg_code.erl"), 
    1816    {eg_code, []} = tests: filter_by_attribute (Binary). 
    1917 
    20 filtering_tests_returns_list_of_MFA_from_unloaded_binary () -> 
    21     File_name = "../fix/eg_test.erl", 
    22     Test = fun ([Ok, Nok]) -> 
    23                    {Ok_m, Ok_f, Ok_a} = Ok, 
    24                    ok = apply (Ok_m, Ok_f, Ok_a), 
    25                    {Nok_m, Nok_f, Nok_a} = Nok, 
    26                    Error = (catch apply (Nok_m, Nok_f, Nok_a)), 
    27                    {'EXIT', {{badmatch, nok}, _}} = Error 
    28            end, 
    29     filtering (File_name, eg_test, Test). 
    30  
    31 filtering_fixtured_tests_returns_list_of_fixture_fun_tuples () -> 
    32     File_name = "../fix/eg_test_fix.erl", 
    33     Test = fun ([{Module, Fixture, [Tests]}]) -> 
    34                    [ok] = Module: Fixture (Tests) 
    35            end, 
    36     filtering (File_name, eg_test_fix, Test). 
    37      
    38 filtering_understands_mixed_export_and_fixtured_tests () -> 
    39     File_name = "../fix/eg_test_fix_nofix.erl", 
    40     Test = fun ([{Module, Fixture, [With]}, Without]) -> 
    41                    {Wo_m, Wo_f, Wo_a} = Without, 
    42                    {'EXIT', {Reason, _}} = (catch apply (Wo_m, Wo_f, Wo_a)), 
    43                    {badmatch, without_fixture_ok} = Reason, 
    44                    [ok] = Module: Fixture (With) 
    45            end, 
    46     filtering (File_name, eg_test_fix_nofix, Test). 
    47  
    48 filtering (File_name, Module, Test) -> 
    49     Binary = modules: to_binary (File_name), 
    50     false = code: is_loaded (Module), 
    51     {Module, Tests} = tests: filter_by_attribute (Binary), 
    52     try 
    53         {module, Module} = code: load_binary (Module, File_name, Binary), 
    54         Test (Tests) 
    55     after 
    56         code: purge (Module), 
    57         code: delete (Module) 
    58     end. 
     18filtering_tests_returns_list_of_tests_from_unloaded_binary () -> 
     19    File = "../fix/eg_test.erl", 
     20    Binary = modules: to_binary (File), 
     21    false = code: is_loaded (eg_test), 
     22    {eg_test, [ok, nok]} = tests: filter_by_attribute (Binary), 
     23    false = code: is_loaded (eg_test). 
Note: See TracChangeset for help on using the changeset viewer.