Changeset 28 for trunk


Ignore:
Timestamp:
06/07/08 09:09:47 (4 years ago)
Author:
dom
Message:

Revealed and fixed problem in tester when two nodes have different code paths

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      forge.log
      tester.log
  • trunk/README

    r16 r28  
    77* To provide a complete, self-contained environment fulfilling the 
    88  needs of extreme programming teams. 
     9* To provide a complete, self-contained environment fulfilling the 
     10  needs of Erlang programmers. 
    911* To explore some of the ideas at the forefront of extreme 
    1012  programming. 
     
    2628Download the tarball, unpack to any convenient location. 
    2729Change to the directory to which you unpacked. 
    28 From the shell, run the 'install' escript: 
     30From the shell, run the 'install' script: 
    2931 
    3032% ./install 
  • trunk/install

    r23 r28  
    1 #!/usr/bin/env escript 
    2 %% -*- erlang -*- 
     1#!/usr/bin/env bash 
     2# -*- sh -*- 
    33 
    4 main (_) -> 
    5     ok = file: set_cwd ("ebin"), 
    6     up_to_date = make: all (), 
    7     ok = tests_test: filter_by_attribute (), 
    8     io: fwrite ("done~n", []). 
     4hostname=`hostname -s` 
     5erl -kernel error_logger "{file,\"tester.log\"}" -sname forgetester -noinput & 
     6cd ebin 
     7erl -make 
     8erl -kernel error_logger "{file,\"../forge.log\"}" -sname forgeinstaller -noinput -s shells install forgetester@$hostname -s init stop 
  • trunk/src/tester.erl

    r26 r28  
    44 
    55-module (tester). 
    6 -export ([init/2, run/2]). 
    7 %%-import (orddict, [new/0]). 
     6-export ([init/2]). 
    87 
    98init (Notify, Node) -> 
     9    process_flag (trap_exit, true), 
     10    loop (Notify, Node). 
     11 
     12loop (Notify, Node) -> 
    1013    receive 
    1114        {File_name, Binary} -> 
    1215            test (File_name, Binary, Notify, Node); 
    1316        _ -> 
    14             init (Notify, Node) 
     17            loop (Notify, Node) 
    1518    end. 
    1619 
    1720test (File_name, Binary, Notify, Node) -> 
    1821    {Module, Tests} = tests: filter_by_attribute (Binary), 
    19     rpc:call (Node, code, load_binary, [Module, File_name, Binary]), 
     22    {module, Module} = rpc: call (Node, code, load_binary, [Module, File_name, Binary]), 
    2023    Total = length (Tests), 
    2124    Notify ({Total, 0, 0}), 
    2225    test (Total, 0, 0, Tests, Notify, Node). 
    2326 
    24 test (Total, Run, Passed, [T | Tests], Notify, Node) -> 
    25     spawn_link (Node, tester, run, [T, self ()]), 
     27test (Total, Run, Passed, [{M, F, A} | Tests], Notify, Node) -> 
     28    Pid = spawn_link (Node, M, F, A), 
    2629    New_passed = 
    2730        receive 
    28             {'EXIT', Reason} -> 
     31            {'EXIT', Pid, normal} -> 
     32                Passed + 1; 
     33            {'EXIT', Pid, Reason} -> 
    2934                Notify (Reason), 
    30                 Passed; 
    31             _ -> 
    32                 Passed + 1 
     35                Passed 
    3336        end, 
    3437    New_run = Run + 1, 
     
    3639    test (Total, New_run, New_passed, Tests, Notify, Node); 
    3740test (_, _, _, [], _, _) -> 
    38 %%    init (Notify, Node). 
    3941    bye. 
    40  
    41 run (Test, Tester) -> 
    42     Result = (catch Test ()), 
    43     Tester ! Result. 
  • trunk/src/tester_test.erl

    r26 r28  
    1515    Tester ! {"../fix/eg_test.erl", Binary}, 
    1616    [{2, 0, 0}, {2, 1, 1}, Error, {2, 2, 1}] = tests: receive_all (), 
    17     {{badmatch, nok}, [{eg_test, nok, 0}, _]} = Error,  
     17    {{badmatch, nok}, [{eg_test, nok, 0} | _]} = Error,  
    1818    false = code: is_loaded (eg_test), 
    1919    ok. 
  • trunk/src/tests.erl

    r26 r28  
    2929    exports_to_funs (M, Exports, Funs); 
    3030exports_to_funs (M, [{F, 0} | Exports], Funs) -> 
    31     Fun = fun () -> M: F () end, 
    32     exports_to_funs (M, Exports, [Fun | Funs]); 
     31    exports_to_funs (M, Exports, [{M, F, []} | Funs]); 
    3332exports_to_funs (M, [{_, _} | Exports], Funs) -> 
    3433    exports_to_funs (M, Exports, Funs); 
     
    4039    after 10000 -> lists: reverse (Ms) 
    4140    end. 
    42                               
  • trunk/src/tests_test.erl

    r25 r28  
    99filter_by_attribute () -> 
    1010    filtering_non_tests_returns_empty_list(), 
    11     filtering_tests_returns_list_of_funs_from_unloaded_binary (), 
     11    filtering_tests_returns_list_of_MFA_from_unloaded_binary (), 
    1212    filtering_fixtured_tests_returns_list_of_fixture_fun_tuples (), 
    1313    filtering_understands_mixed_export_and_fixtured_tests (), 
     
    1818    {eg_code, []} = tests: filter_by_attribute (Binary). 
    1919 
    20 filtering_tests_returns_list_of_funs_from_unloaded_binary () -> 
     20filtering_tests_returns_list_of_MFA_from_unloaded_binary () -> 
    2121    File_name = "../fix/eg_test.erl", 
    2222    Test = fun ([Ok, Nok]) -> 
    23                    ok = Ok (), 
    24                    {'EXIT', {{badmatch, nok}, _}} = (catch 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 
    2528           end, 
    2629    filtering (File_name, eg_test, Test). 
     
    3639    File_name = "../fix/eg_test_fix_nofix.erl", 
    3740    Test = fun ([{Module, Fixture, With}, Without]) -> 
    38                    {'EXIT', {Reason, _}} = (catch Without ()), 
     41                   {Wo_m, Wo_f, Wo_a} = Without, 
     42                   {'EXIT', {Reason, _}} = (catch apply (Wo_m, Wo_f, Wo_a)), 
    3943                   {badmatch, without_fixture_ok} = Reason, 
    4044                   [ok] = Module: Fixture (With) 
Note: See TracChangeset for help on using the changeset viewer.