Skip to content

Commit

Permalink
split test by os
Browse files Browse the repository at this point in the history
  • Loading branch information
falood committed Nov 9, 2023
1 parent efc641b commit 969f9e6
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:

- run: mix compile --warnings-as-errors

- run: mix test
- run: mix test --only os_macos
2 changes: 1 addition & 1 deletion .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix test
- run: mix test --only os_linux
2 changes: 1 addition & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix test
- run: mix test --only os_windows
110 changes: 110 additions & 0 deletions test/backends/fs_inotify_linux_test.exs
Original file line number Diff line number Diff line change
@@ -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
104 changes: 2 additions & 102 deletions test/backends/fs_inotify_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
114 changes: 114 additions & 0 deletions test/backends/fs_inotify_windows_test.exs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions test/backends/fs_mac_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down
2 changes: 2 additions & 0 deletions test/backends/fs_poll_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
2 changes: 2 additions & 0 deletions test/file_system_test.exs
Original file line number Diff line number Diff line change
@@ -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

Check failure on line 6 in test/file_system_test.exs

View workflow job for this annotation

GitHub Actions / test (1.12.3, 23.3)

test file event api (FileSystemTest)
tmp_dir = System.cmd("mktemp", ["-d"]) |> elem(0) |> String.trim()
{:ok, pid} = FileSystem.start_link(dirs: [tmp_dir])
Expand Down

0 comments on commit 969f9e6

Please sign in to comment.