Created
September 25, 2024 14:52
-
-
Save Dkendal/2fa71048e63af3bd4850a9ef0a5e2fe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env elixir | |
for path <- Path.wildcard("_build/test/lib/*/.mix/.mix_test_failures", match_dot: true), | |
{{mod, name}, path} <- | |
path | |
|> File.read!() | |
|> :erlang.binary_to_term() | |
|> elem(1) | |
|> Map.to_list(), | |
grep_match <- | |
name | |
|> to_string() | |
|> String.split() | |
|> Stream.unfold(fn | |
[] -> | |
nil | |
[_ | words] -> | |
search_term = Enum.join(words, " ") | |
System.cmd("rg", ["-w", search_term, "--vimgrep", path]) | |
|> case do | |
{"", 1} -> {nil, words} | |
{matches, 0} -> {matches, []} | |
end | |
end) | |
|> Stream.reject(&is_nil/1) | |
|> Enum.to_list(), | |
into: IO.stream(:stdio, :line) do | |
[path, line, col, _] = String.split(grep_match, ":", parts: 4) | |
"#{Path.relative_to_cwd(path)}:#{line}:#{col}: #{mod} #{name}\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment