Skip to content

Commit

Permalink
Resolve relative paths in exunit filter (#13258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara authored Jan 17, 2024
1 parent 4b568d2 commit fe649fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ex_unit/lib/ex_unit/filters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule ExUnit.Filters do
end

defp extract_line_numbers(file_path) do
case String.split(file_path, ":") do
case Path.relative_to_cwd(file_path) |> String.split(":") do
[path] ->
{path, []}

Expand Down
5 changes: 3 additions & 2 deletions lib/ex_unit/test/ex_unit/filters_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ defmodule ExUnit.FiltersTest do
test "file paths with line numbers" do
unix_path = "test/some/path.exs"
windows_path = "C:\\some\\path.exs"
unix_path_with_dot = "./test/some/path.exs"

for path <- [unix_path, windows_path] do
fixed_path = path |> Path.split() |> Path.join()
for path <- [unix_path, windows_path, unix_path_with_dot] do
fixed_path = path |> Path.split() |> Path.join() |> Path.relative_to_cwd()

assert ExUnit.Filters.parse_path("#{path}:123") ==
{fixed_path, [exclude: [:test], include: [location: {fixed_path, 123}]]}
Expand Down

0 comments on commit fe649fe

Please sign in to comment.