Changeset 54


Ignore:
Timestamp:
04/16/09 21:01:49 (3 years ago)
Author:
dom
Message:

Added tests and improved recursive directory_watcher.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/directory_watcher.erl

    r53 r54  
    6565            loop_recursive (Directory, Pid, Watchers); 
    6666        check -> 
    67             lists: foreach (fun (P) -> P ! check end, Watchers); 
     67            lists: foreach (fun (P) -> P ! check end, Watchers), 
     68            loop_recursive (Directory, Pid, Watchers); 
    6869        stop -> 
    6970            notify (Pid, bye) 
  • trunk/src/directory_watcher_test.erl

    r53 r54  
    3737 
    3838recursive () -> 
     39    Subsub = {directory, "subsubdir", 
     40              [{file, "subsubfile.sub", "titi"}]}, 
    3941    Tree = [{file, "foo.txt", "Hello"}, 
    4042            {file, "bar.txt", "G'day"}, 
    4143            {file, "toto.erl", "-module(toto)."}, 
    42             {directory, "subdir", [{file, "subfile.ext", "toto"}]}], 
     44            {directory, "subdir", 
     45             [{file, "subfile.ext", "toto"}, 
     46              Subsub]}], 
    4347    ok = fixtures: use_tree (Tree, fun recursive/2). 
    4448 
    4549recursive (Dir, _) -> 
    4650    Watcher = spawn_link (directory_watcher, init_recursive, [Dir, self ()]), 
    47     Filename = filename: join ([Dir, "subdir", "subfile.ext"]), 
    48     Expected = {{file, ".ext"}, Filename, found}, 
    49     ok = receive_until_found (Expected). 
     51    Subdir = filename: join (Dir, "subdir"), 
     52    Found_subdir = {directory, Subdir, found}, 
     53    ok = receive_until_found (Found_subdir), 
     54    Subfile = filename: join (Subdir, "subfile.ext"), 
     55    Found_subfile = {{file, ".ext"}, Subfile, found}, 
     56    ok = receive_until_found (Found_subfile), 
     57    Subsubfile = filename: join ([Subdir, "subsubdir", "subsubfile.sub"]), 
     58    Found_subsub = {{file, ".sub"}, Subsubfile, found}, 
     59    ok = receive_until_found (Found_subsub), 
     60    ok = file: write_file (Subsubfile, "not titi"), 
     61    Watcher ! check, 
     62    Change_subsub = {{file, ".sub"}, Subsubfile, changed}, 
     63    ok = receive_until_found (Change_subsub).     
    5064 
    5165bad_symlinks_are_ignored (Dir, _) -> 
Note: See TracChangeset for help on using the changeset viewer.