Skip to content

Commit 111b48d

Browse files
committed
Resolve relative paths in exunit filter (#13258)
1 parent 6dccefe commit 111b48d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/ex_unit/lib/ex_unit/filters.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule ExUnit.Filters do
4545
end
4646

4747
defp extract_line_numbers(file_path) do
48-
case String.split(file_path, ":") do
48+
case Path.relative_to_cwd(file_path) |> String.split(":") do
4949
[path] ->
5050
{path, []}
5151

lib/ex_unit/test/ex_unit/filters_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ defmodule ExUnit.FiltersTest do
196196
test "file paths with line numbers" do
197197
unix_path = "test/some/path.exs"
198198
windows_path = "C:\\some\\path.exs"
199+
unix_path_with_dot = "./test/some/path.exs"
199200

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

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

0 commit comments

Comments
 (0)