diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 1501f8c..1e8b1c4 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -35,4 +35,4 @@ jobs: - run: mix compile --warnings-as-errors - - run: mix test + - run: mix test --only os_macos diff --git a/.github/workflows/ci-ubuntu.yml b/.github/workflows/ci-ubuntu.yml index 86c582d..976136e 100644 --- a/.github/workflows/ci-ubuntu.yml +++ b/.github/workflows/ci-ubuntu.yml @@ -55,4 +55,4 @@ jobs: - run: mix compile --warnings-as-errors if: ${{ matrix.lint }} - - run: mix test + - run: mix test --only os_linux diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 1aa38bc..a14cede 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -44,4 +44,4 @@ jobs: - run: mix compile --warnings-as-errors if: ${{ matrix.lint }} - - run: mix test + - run: mix test --only os_windows diff --git a/test/backends/fs_inotify_linux_test.exs b/test/backends/fs_inotify_linux_test.exs new file mode 100644 index 0000000..6408132 --- /dev/null +++ b/test/backends/fs_inotify_linux_test.exs @@ -0,0 +1,110 @@ +defmodule FileSystem.Backends.FSInotifyLinuxTest do + use ExUnit.Case, async: true + import FileSystem.Backends.FSInotify + + @moduletag os_inux: true + + describe "options parse test" do + test "supported options" do + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"-r", + ~c"/tmp" + ]} == + parse_options(dirs: ["/tmp"], recursive: true) + + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"/tmp" + ]} == + parse_options(dirs: ["/tmp"], recursive: false) + end + + test "ignore unsupported options" do + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"/tmp" + ]} == + parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options) + + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"-r", + ~c"/tmp" + ]} == + parse_options(dirs: ["/tmp"], recursive: :unknown_value) + end + end +end diff --git a/test/backends/fs_inotify_test.exs b/test/backends/fs_inotify_test.exs index 87b44f2..f2f6daf 100644 --- a/test/backends/fs_inotify_test.exs +++ b/test/backends/fs_inotify_test.exs @@ -2,113 +2,13 @@ defmodule FileSystem.Backends.FSInotifyTest do use ExUnit.Case, async: true import FileSystem.Backends.FSInotify + @moduletag os_inux: true, os_windows: true + describe "options parse test" do test "without :dirs" do assert {:error, _} = parse_options([]) assert {:error, _} = parse_options(recursive: 1) end - - test "supported options" do - assert {:ok, - [ - ~c"-e", - ~c"modify", - ~c"-e", - ~c"close_write", - ~c"-e", - ~c"moved_to", - ~c"-e", - ~c"moved_from", - ~c"-e", - ~c"create", - ~c"-e", - ~c"delete", - ~c"-e", - ~c"attrib", - ~c"--format", - [37, 119, 1, 37, 101, 1, 37, 102], - ~c"--quiet", - ~c"-m", - ~c"-r", - ~c"/tmp" - ]} == - parse_options(dirs: ["/tmp"], recursive: true) - - assert {:ok, - [ - ~c"-e", - ~c"modify", - ~c"-e", - ~c"close_write", - ~c"-e", - ~c"moved_to", - ~c"-e", - ~c"moved_from", - ~c"-e", - ~c"create", - ~c"-e", - ~c"delete", - ~c"-e", - ~c"attrib", - ~c"--format", - [37, 119, 1, 37, 101, 1, 37, 102], - ~c"--quiet", - ~c"-m", - ~c"/tmp" - ]} == - parse_options(dirs: ["/tmp"], recursive: false) - end - - test "ignore unsupported options" do - assert {:ok, - [ - ~c"-e", - ~c"modify", - ~c"-e", - ~c"close_write", - ~c"-e", - ~c"moved_to", - ~c"-e", - ~c"moved_from", - ~c"-e", - ~c"create", - ~c"-e", - ~c"delete", - ~c"-e", - ~c"attrib", - ~c"--format", - [37, 119, 1, 37, 101, 1, 37, 102], - ~c"--quiet", - ~c"-m", - ~c"/tmp" - ]} == - parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options) - - assert {:ok, - [ - ~c"-e", - ~c"modify", - ~c"-e", - ~c"close_write", - ~c"-e", - ~c"moved_to", - ~c"-e", - ~c"moved_from", - ~c"-e", - ~c"create", - ~c"-e", - ~c"delete", - ~c"-e", - ~c"attrib", - ~c"--format", - [37, 119, 1, 37, 101, 1, 37, 102], - ~c"--quiet", - ~c"-m", - ~c"-r", - ~c"/tmp" - ]} == - parse_options(dirs: ["/tmp"], recursive: :unknown_value) - end end describe "port line parse test" do diff --git a/test/backends/fs_inotify_windows_test.exs b/test/backends/fs_inotify_windows_test.exs new file mode 100644 index 0000000..2eb7735 --- /dev/null +++ b/test/backends/fs_inotify_windows_test.exs @@ -0,0 +1,114 @@ +defmodule FileSystem.Backends.FSInotifyWindowsTest do + use ExUnit.Case, async: true + import FileSystem.Backends.FSInotify + + @moduletag os_windows: true + + describe "options parse test" do + test "supported options" do + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"-r", + tmp_dir + ]} = parse_options(dirs: ["/tmp"], recursive: true) + + assert tmp_dir |> to_string() |> String.ends_with?("/tmp") + + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + tmp_dir + ]} = parse_options(dirs: ["/tmp"], recursive: false) + + assert tmp_dir |> to_string() |> String.ends_with?("/tmp") + end + + test "ignore unsupported options" do + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + tmp_dir + ]} = parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options) + + assert tmp_dir |> to_string() |> String.ends_with?("/tmp") + + assert {:ok, + [ + ~c"-e", + ~c"modify", + ~c"-e", + ~c"close_write", + ~c"-e", + ~c"moved_to", + ~c"-e", + ~c"moved_from", + ~c"-e", + ~c"create", + ~c"-e", + ~c"delete", + ~c"-e", + ~c"attrib", + ~c"--format", + [37, 119, 1, 37, 101, 1, 37, 102], + ~c"--quiet", + ~c"-m", + ~c"-r", + tmp_dir + ]} = parse_options(dirs: ["/tmp"], recursive: :unknown_value) + + assert tmp_dir |> to_string() |> String.ends_with?("/tmp") + end + end +end diff --git a/test/backends/fs_mac_test.exs b/test/backends/fs_mac_test.exs index 0a64d66..f1fbd0a 100644 --- a/test/backends/fs_mac_test.exs +++ b/test/backends/fs_mac_test.exs @@ -2,6 +2,8 @@ defmodule FileSystem.Backends.FSMacTest do use ExUnit.Case, async: true import FileSystem.Backends.FSMac + @moduletag os_macos: true + describe "options parse test" do test "without :dirs" do assert {:error, _} = parse_options([]) diff --git a/test/backends/fs_poll_test.exs b/test/backends/fs_poll_test.exs index 39c1f23..b38e6bc 100644 --- a/test/backends/fs_poll_test.exs +++ b/test/backends/fs_poll_test.exs @@ -2,6 +2,8 @@ defmodule FileSystem.Backends.FSPollTest do use ExUnit.Case, async: true import FileSystem.Backends.FSPoll + @moduletag os_linux: true, os_macos: true, os_windows: true + @mtime1 {{2017, 11, 13}, {10, 14, 00}} @mtime2 {{2017, 11, 13}, {10, 15, 00}} diff --git a/test/file_system_test.exs b/test/file_system_test.exs index 7b59b6d..69823f1 100644 --- a/test/file_system_test.exs +++ b/test/file_system_test.exs @@ -1,6 +1,8 @@ defmodule FileSystemTest do use ExUnit.Case, async: true + @moduletag os_linux: true, os_macos: true, os_windows: true + test "file event api" do tmp_dir = System.cmd("mktemp", ["-d"]) |> elem(0) |> String.trim() {:ok, pid} = FileSystem.start_link(dirs: [tmp_dir])