Changeset 63


Ignore:
Timestamp:
07/13/09 11:17:12 (3 years ago)
Author:
dom
Message:

compiler now recompiles minimally when file changes.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/compiler.erl

    r62 r63  
    1212receive_files (Notify, Watcher, Modules, New) -> 
    1313    receive 
    14         {Watcher, {{file, ".erl"}, File, found}} -> 
    15             receive_files (Notify, Watcher, Modules, dict: store (File, found, New)); 
     14        {Watcher, {{file, ".erl"}, File, Event}} when Event == found; Event == changed -> 
     15            receive_files (Notify, Watcher, Modules, dict: store (File, Event, New)); 
    1616        {Watcher, _} -> 
    1717            receive_files (Notify, Watcher, Modules, New) 
     
    3030    loop (Notify, Watcher, Processed). 
    3131 
    32 process (File, found, {Modules, Notify, Binaries}) -> 
     32process (File, Event, {Modules, Notify, Binaries}) when Event == found; 
     33                                                        Event == changed -> 
    3334    Result = modules: compile (File), 
    3435    notify_result (Result, Notify), 
  • trunk/src/compiler_test.erl

    r62 r63  
    77-export ([compiles_and_reports_progress_warnings_and_errors/0]). 
    88-export ([provides_binaries_when_all_compiled/0]). 
     9-export ([recompiles_minimally_after_change/0]). 
    910-include_lib("stdlib/include/ms_transform.hrl"). 
    1011 
     
    1718provides_binaries_when_all_compiled () -> 
    1819    F = fun provides_binaries_when_all_compiled/2, 
     20    ok = fixtures: use_tree (good_erl_tree (), F). 
     21 
     22recompiles_minimally_after_change () -> 
     23    F = fun recompiles_minimally_after_change/2, 
    1924    ok = fixtures: use_tree (good_erl_tree (), F). 
    2025 
     
    3035    ok. 
    3136 
    32 %% stops 
     37recompiles_minimally_after_change (Root, _) -> 
     38    Compiler = spawn_link (compiler, init, [notify_me (), Root]), 
     39    receive_all (), 
     40    File = filename: join (Root, "hello.erl"), 
     41    Bin = list_to_binary ("-module(hello). -export([run/0]). run()->hello_howdy."), 
     42    ok = file: write_file (File, Bin), 
     43    [{2, 1, 1}, {2, 2, 2}, {binaries, [B]}] = receive_all (), 
     44    Compiler ! stop, 
     45    {ok, {hello, _}} = beam_lib: chunks (B, [exports]), 
     46    ok. 
    3347 
    34 %% empty tree 
    35  
     48%% More tests: 
     49%% - stops 
     50%% - empty tree 
     51%% - add a file 
     52%% - remove a file 
    3653 
    3754check ([{Total, 0, 0} | _] = Xs, unknown) -> 
  • trunk/src/shells.erl

    r45 r63  
    1111        receive {Self, done} -> ok; 
    1212                M -> io:fwrite ("tests_crash: ~p~n", [M]) 
    13         after 20000 -> throw ("tests timed out~n") 
     13        after 30000 -> throw ("tests timed out~n") 
    1414        end 
    1515 
Note: See TracChangeset for help on using the changeset viewer.