Changeset 80
- Timestamp:
- 07/17/09 13:31:39 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
doc/TODO (modified) (1 diff)
-
src/adlib.erl (added)
-
src/adlib_test.erl (added)
-
src/compiler_test.erl (modified) (2 diffs)
-
src/directory_watcher.erl (modified) (3 diffs)
-
src/directory_watcher_test.erl (modified) (3 diffs)
-
src/shells_tests.erl (modified) (1 diff)
-
src/tests_test.erl (modified) (2 diffs)
-
src/text_printer_test.erl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/TODO
r79 r80 1 1 -*- mode: text -*- 2 2 3 Known bugs:4 ---------- 3 Known issues: 4 ------------ 5 5 6 text_printer probably prints too many \n when two errors in a row. 6 - text_printer doesn't yet handle file removals. 7 - fixtures:make_tree doesn't like {file, "a", "a"} in tree. 7 8 8 9 Check for possible bugs: -
trunk/src/compiler_test.erl
r71 r80 16 16 17 17 compiles_and_reports_progress_warnings_and_errors () -> 18 Compiler = spawn_link (compiler, init, [notify_me (), " fix"]),18 Compiler = spawn_link (compiler, init, [notify_me (), "/home/dom/forge/fix"]), 19 19 Compiler ! check, 20 20 Ms = receive_all (), … … 23 23 24 24 stops () -> 25 Compiler = spawn_link (compiler, init, [notify_me (), " fix"]),25 Compiler = spawn_link (compiler, init, [notify_me (), "/home/com/forge/fix"]), 26 26 Compiler ! check, 27 27 receive_all (), -
trunk/src/directory_watcher.erl
r75 r80 6 6 -export ([init/2]). 7 7 -export ([init_recursive/2]). 8 -export([start_io/2]).9 -export([start_io/0]).10 8 -include_lib ("kernel/include/file.hrl"). 11 9 12 start_io () ->13 start_io (".", 3000).14 15 start_io (Dir, Interval) ->16 Watcher = spawn_link (?MODULE, init_recursive, [Dir, self ()]),17 io_loop (Interval, Watcher).18 19 io_loop (Interval, Watcher) ->20 Watcher ! check,21 receive22 {directory_watcher, _, Event} ->23 io: fwrite ("~p~n", [Event]),24 io_loop (Interval, Watcher);25 stop ->26 bye27 after Interval ->28 io_loop (Interval, Watcher)29 end.30 31 10 init (Directory, F) -> 32 check (Directory, F, []). 11 D = filename: absname (Directory), 12 check (D, F, []). 33 13 34 14 init_recursive (Directory, F) -> 15 D = filename: absname (Directory), 35 16 Self = self (), 36 Watcher = spawn_link (?MODULE, init, [D irectory, send (Self)]),37 loop_recursive (D irectory, F, [Watcher]).17 Watcher = spawn_link (?MODULE, init, [D, send (Self)]), 18 loop_recursive (D, F, [Watcher]). 38 19 39 20 check (Directory, F, State) -> 40 21 New_state = list_dir (Directory, F), 41 compare (F, State, New_state),22 sort_and_compare (F, State, New_state), 42 23 loop (Directory, F, New_state). 43 24 … … 99 80 end. 100 81 101 compare (_, State, State) -> 102 done; 103 compare (Fun, [X | Xs], [X | Ys]) -> 104 compare (Fun, Xs, Ys); 105 compare (Fun, [{F, {regular, _}} | Xs], [{F, {regular, _}} | Ys]) -> 106 report_changed (Fun, F), 107 compare (Fun, Xs, Ys); 108 compare (Fun, [{F, _}=X | Xs], [{F, _} | Ys]) -> 109 report_lost (Fun, X), 110 report_found (Fun, F), 111 compare (Fun, Xs, Ys); 112 compare (Fun, [X, {F, V} | Xs], [{F, W} | Ys]) -> 113 report_lost (Fun, X), 114 compare (Fun, [{F, V} | Xs], [{F, W} | Ys]); 115 compare (Fun, [{F, V} | Xs], [Y, {F, W} | Ys]) -> 116 {Filename, _} = Y, 117 report_found (Fun, Filename), 118 compare (Fun, [{F, V} | Xs], [{F, W} | Ys]); 119 compare (Fun, [], [Y | Ys]) -> 120 {Filename, _} = Y, 121 report_found (Fun, Filename), 122 compare (Fun, [], Ys); 123 compare (Fun, [X | Xs], []) -> 124 report_lost (Fun, X), 125 compare (Fun, Xs, []); 126 compare (Fun, [X], [Y]) -> 127 report_lost (Fun, X), 128 {File, _} = Y, 129 report_found (Fun, File), 130 done; 131 compare (_, [], []) -> 82 sort_and_compare (F, Old, New) -> 83 Original = dict: from_list (Old), 84 Modified = dict: from_list (New), 85 Compared = adlib: compare_dict (Modified, Original), 86 dict: fold (fun notify_new/3, F, dict: fetch (new, Compared)), 87 dict: fold (fun notify_lost/3, F, dict: fetch (lost, Compared)), 88 dict: fold (fun notify_changed/3, F, dict: fetch (changed, Compared)), 132 89 done. 90 91 notify_new (File_name, _, Fun) -> 92 report_found (Fun, File_name), 93 Fun. 133 94 134 95 report_found (F, Filename) -> 135 96 F ({type (Filename), Filename, found}). 97 98 notify_lost (File_name, Value, Fun) -> 99 report_lost (Fun, {File_name, Value}), 100 Fun. 136 101 137 102 report_lost (F, {Filename, directory}) -> … … 139 104 report_lost (F, {Filename, {regular, _}}) -> 140 105 F ({{file, filename: extension (Filename)}, Filename, lost}). 106 107 notify_changed (File_name, {{regular, _}, {regular, _}}, Fun) -> 108 report_changed (Fun, File_name), 109 Fun; 110 notify_changed (File_name, {_, Original}, Fun) -> 111 report_lost (Fun, {File_name, Original}), 112 report_found (Fun, File_name), 113 Fun. 141 114 142 115 report_changed (F, Filename) -> -
trunk/src/directory_watcher_test.erl
r75 r80 17 17 -export ([change_from_file_to_directory_when_recursive/0]). 18 18 -export ([remove_and_add_in_same_check/0]). 19 -export ([insensitive_to_cwd/0]). 20 -export ([can_replace_all_in_same_check/0]). 21 -export ([can_find_two_at_a_time/0]). 22 -export([tree/0]). 19 23 20 24 tests_from_empty () -> … … 71 75 remove_and_add_in_same_check () -> 72 76 F = fun remove_and_add_in_same_check/2, 77 ok = fixtures: use_tree ([{file, "foo", "foo"}], F). 78 79 insensitive_to_cwd () -> 80 Watcher = spawn_link (directory_watcher, init, ["/home/dom/forge/fix", send_me ()]), 81 receive_all (), 82 ok = file: set_cwd ("/tmp"), 83 Watcher ! check, 84 true = is_process_alive (Watcher), 85 [] = receive_all (), 86 ok. 87 88 can_replace_all_in_same_check () -> 89 Tree = [{file, X, X} || X <- ["foo", "bar", "baz"]], 90 F = fun can_replace_all_in_same_check/2, 91 ok = fixtures: use_tree (Tree, F). 92 93 can_find_two_at_a_time () -> 94 F = fun can_find_two_at_a_time/2, 73 95 ok = fixtures: use_tree ([{file, "foo", "foo"}], F). 74 96 … … 267 289 ok = file: write_file (Bar, list_to_binary ("bar")), 268 290 Watcher ! check, 269 [{{file, ""}, Foo, lost}, 270 {{file, ""}, Bar, found}] = receive_all (), 271 ok. 272 291 [{{file, ""}, Bar, found}, 292 {{file, ""}, Foo, lost}] = receive_all (), 293 ok. 294 295 can_replace_all_in_same_check (Root, Tree) -> 296 Watcher = spawn_link (directory_watcher, init, [Root, send_me ()]), 297 receive_all (), 298 Replace = fun ({file, F, _}) -> 299 Old = filename: join (Root, F), 300 ok = file: delete (Old), 301 New = filename: join (Root, F ++ F), 302 ok = file: write_file (New, "hello") 303 end, 304 ok = lists: foreach (Replace, Tree), 305 Watcher ! check, 306 Lost_files = [filename: join (Root, X) || {file, X, _} <- Tree], 307 Found_files = [filename: join (Root, X++X) || {file, X, _} <- Tree], 308 Lost = [{{file, ""}, X, lost} || X <- Lost_files], 309 Found = [{{file, ""}, X, found} || X <- Found_files], 310 Expected = lists: sort (Lost ++ Found), 311 Received = lists: sort (receive_all ()), 312 {Expected, Expected} = {Expected, Received}, 313 ok. 314 315 can_find_two_at_a_time (Root, _) -> 316 Watcher = spawn_link (directory_watcher, init, [Root, send_me ()]), 317 receive_all (), 318 [Bar, Baz] = [filename: join (Root, X) || X <- ["bar", "baz"]], 319 ok = file: write_file (Bar, "bar"), 320 ok = file: write_file (Baz, "baz"), 321 Watcher ! check, 322 Found = [{{file, ""}, X, found} || X <- [Bar, Baz]], 323 Expected = lists: sort (Found), 324 Received = lists: sort (receive_all ()), 325 {Expected, Expected} = {Expected, Received}, 326 ok. 273 327 274 328 send_me () -> -
trunk/src/shells_tests.erl
r76 r80 15 15 compiler_test, compiler, 16 16 modules_test, modules, 17 text_printer_test, text_printer], 17 text_printer_test, text_printer, 18 adlib_test, adlib], 18 19 ok = hand_send_to_tester (Modules, Test_node), 19 20 Caller ! {Caller, done}. -
trunk/src/tests_test.erl
r73 r80 14 14 15 15 non_tests_returns_empty_list () -> 16 Binary = modules: to_binary (" ../fix/eg_code.erl"),16 Binary = modules: to_binary ("/home/dom/forge/fix/eg_code.erl"), 17 17 {_, eg_code, []} = tests: filter_by_attribute (Binary). 18 18 19 19 test_exports_returns_list_of_tests_from_unloaded_binary () -> 20 File = " ../fix/eg_test.erl",20 File = "/home/dom/forge/fix/eg_test.erl", 21 21 Binary = modules: to_binary (File), 22 22 false = code: is_loaded (eg_test), … … 25 25 26 26 test_non_exports_also () -> 27 File = " ../fix/eg_test_not_exports.erl",27 File = "/home/dom/forge/fix/eg_test_not_exports.erl", 28 28 Binary = modules: to_binary (File), 29 29 false = code: is_loaded (eg_test_not_exports), -
trunk/src/text_printer_test.erl
r77 r80 24 24 P ! {self (), compiler, {4, 4, 3}}, 25 25 <<".\n3/4 successfully compiled.\nCannot run tests.\n">> = receive_io_request (P), 26 P ! {self (), compiler, {4, 3, 3}},26 P ! {self (), compiler, {4, 3, 2}}, 27 27 <<"Compiling 1: ">> = receive_io_request (P), 28 28 P ! {self (), compiler, {4, 4, 4}},
Note: See TracChangeset
for help on using the changeset viewer.
