Skip to content

Commit cacfd2e

Browse files
committed
test(watcher): enable running on macos
they still aren't working well, but at least they're running. Signed-off-by: Rudi Grinberg <[email protected]>
1 parent b88987a commit cacfd2e

File tree

4 files changed

+14
-33
lines changed

4 files changed

+14
-33
lines changed

src/dune_file_watcher/dune_file_watcher.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,17 +509,6 @@ let add_watch t path =
509509
()
510510
| Inotify inotify -> Inotify_lib.add inotify (Path.to_string path)
511511

512-
module For_tests = struct
513-
let pid t =
514-
match t.kind with
515-
| Fswatch c -> c.pid
516-
| _ -> failwith "pid unavailable"
517-
518-
let suspend t = Unix.kill (Pid.to_int (pid t)) Sys.sigstop
519-
520-
let resume t = Unix.kill (Pid.to_int (pid t)) Sys.sigcont
521-
end
522-
523512
let ignore_next_file_change_event t path =
524513
assert (Path.is_in_source_tree path);
525514
Table.set t.ignored_files (Path.to_absolute_filename path) ()

src/dune_file_watcher/dune_file_watcher.mli

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ val wait_for_initial_watches_established_blocking : t -> unit
7272
far. *)
7373
val emit_sync : unit -> unit
7474

75-
module For_tests : sig
76-
val suspend : t -> unit
77-
78-
val resume : t -> unit
79-
end
80-
8175
val add_watch : t -> Path.t -> unit
8276

8377
(** Ignore the ne next file change event about this file. *)

test/expect-tests/dune_file_watcher/dune

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
(name dune_file_watcher_tests_macos)
88
(modules dune_file_watcher_tests_macos)
99
(inline_tests
10-
(enabled_if (= %{system} macosx))
10+
(enabled_if
11+
(= %{system} macosx))
1112
(deps
1213
(sandbox always)))
1314
(libraries

test/expect-tests/dune_file_watcher/dune_file_watcher_tests_macos.ml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,27 @@ let%expect_test _ =
3939
Dune_file_watcher.wait_for_initial_watches_established_blocking watcher;
4040
Stdio.Out_channel.write_all "x" ~data:"x";
4141
print_events 1;
42-
[%expect {|
42+
[%expect
43+
{|
4344
{ path = In_source_tree "."; kind = "Created" }
4445
{ path = In_source_tree "x"; kind = "Unknown" }
4546
Got more events than expected: expected 1, saw 2 |}];
4647
Unix.rename "x" "y";
4748
print_events 0;
4849
[%expect {|
4950
|}];
50-
Dune_file_watcher.For_tests.suspend watcher;
5151
let (_ : _) = Fpath.mkdir_p "d/w" in
5252
Stdio.Out_channel.write_all "d/w/x" ~data:"x";
53-
Dune_file_watcher.For_tests.resume watcher;
5453
print_events 0;
55-
[%expect.unreachable];
54+
[%expect {||}];
5655
Stdio.Out_channel.write_all "d/w/y" ~data:"y";
5756
print_events 1;
58-
[%expect.unreachable]
59-
[@@expect.uncaught_exn {|
60-
(* CR expect_test_collector: This test expectation appears to contain a backtrace.
61-
This is strongly discouraged as backtraces are fragile.
62-
Please change this test to not include a backtrace. *)
63-
64-
(Failure "pid unavailable")
65-
Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
66-
Called from Dune_file_watcher.For_tests.suspend in file "src/dune_file_watcher/dune_file_watcher.ml", line 518, characters 40-47
67-
Called from Dune_file_watcher_tests_macos.(fun) in file "test/expect-tests/dune_file_watcher/dune_file_watcher_tests_macos.ml", line 47, characters 2-45
68-
Called from Expect_test_collector.Make.Instance.exec in file "collector/expect_test_collector.ml", line 244, characters 12-19 |}]
57+
[%expect
58+
{|
59+
{ path = In_source_tree "x"; kind = "Unknown" }
60+
{ path = In_source_tree "y"; kind = "Unknown" }
61+
{ path = In_source_tree "d"; kind = "Created" }
62+
{ path = In_source_tree "d/w"; kind = "Created" }
63+
{ path = In_source_tree "d/w/x"; kind = "Unknown" }
64+
{ path = In_source_tree "d/w/y"; kind = "Unknown" }
65+
Got more events than expected: expected 1, saw 6 |}]

0 commit comments

Comments
 (0)