Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Whenever that happens, you have a few options:
|`y`|Accept|Accept the proposed change. The assertion will be re-run and should pass.|
|`n`|Reject|Reject the proposed change and fail the test.|
|`s`|Skip|Skip this assertion. The test will not fail, but the `mix test` process will exit with `1`.|
|`S`|Skip All|Skip all remaining assertions and exit. The tests will not fail, but the `mix test` process will exit with `1`.|
|`k`|Next|If multiple patterns have been generated, cycle to the next one.|
|`K`|Last|If multiple patterns have been generated, cycle to the last one.|
|`j`|Previous|If multiple patterns have been generated, cycle to the previous one.|
Expand Down
6 changes: 6 additions & 0 deletions lib/mneme/assertion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ defmodule Mneme.Assertion do
end

defp handle_assertion({:error, :skipped}, assertion, _, _), do: {assertion, []}

defp handle_assertion({:error, :skipped_all}, assertion, _, _) do
Mneme.Server.skip_all()
{assertion, []}
end

defp handle_assertion({:error, :file_changed}, assertion, _, _), do: {assertion, []}
defp handle_assertion({:error, :rejected}, _, _, nil), do: assertion_error!()

Expand Down
3 changes: 3 additions & 0 deletions lib/mneme/patcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ defmodule Mneme.Patcher do
:skip ->
{{:error, :skipped}, project}

:skip_all ->
{{:error, :skipped_all}, project}

select ->
prompt_and_patch!(project, Assertion.select(assertion, select), counter, node)
end
Expand Down
3 changes: 3 additions & 0 deletions lib/mneme/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ defmodule Mneme.Server do
{{:error, :skipped}, _} ->
inc_stat(state, :skipped)

{{:error, :skipped_all}, _} ->
inc_stat(state, :skipped)

{{:error, :rejected}, _} ->
inc_stat(state, :rejected)

Expand Down
2 changes: 2 additions & 0 deletions lib/mneme/terminal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ defmodule Mneme.Terminal do
"y" -> :accept
"n" -> :reject
"s" -> :skip
"S" -> :skip_all
"k" -> :next
"K" -> :last
"j" -> :prev
Expand Down Expand Up @@ -292,6 +293,7 @@ defmodule Mneme.Terminal do
[tag("y", :green), " ", tag("yes", :faint)],
[tag("n", :red), " ", tag("no", :faint)],
[tag("s", :yellow), " ", tag("skip", :faint)],
[tag("S", :yellow), " ", tag("skip all", :faint)],
format_nav_options(assertion)
],
[" "]
Expand Down
10 changes: 5 additions & 5 deletions test/mneme/terminal_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Mneme.TerminalTest do

Accept new assertion?
>
y yes n no s skip
y yes n no s skip S skip all
""" <- message(mock_assertion())

auto_assert """
Expand All @@ -30,7 +30,7 @@ defmodule Mneme.TerminalTest do

Accept new assertion?
>
y yes n no s skip
y yes n no s skip S skip all
""" <- message(mock_assertion(), %{diff: :semantic})

auto_assert """
Expand All @@ -43,7 +43,7 @@ defmodule Mneme.TerminalTest do

Accept new assertion?
>
y yes n no s skip
y yes n no s skip S skip all
""" <-
message(mock_assertion(), %{
diff: :semantic,
Expand All @@ -64,7 +64,7 @@ defmodule Mneme.TerminalTest do

Accept new assertion?
>
y yes n no s skip ❮ J/j ●○○ k/K ❯
y yes n no s skip S skip all ❮ J/j ●○○ k/K ❯
""" <- message(assertion)
end

Expand All @@ -80,7 +80,7 @@ defmodule Mneme.TerminalTest do

Value has changed! Update pattern?
>
y yes n no s skip
y yes n no s skip S skip all
""" <- message(assertion)
end
end
Expand Down
18 changes: 18 additions & 0 deletions test_integration/skipped_all_assertion_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# exit: 2
defmodule Mneme.Integration.SkippedAllAssertionTest do
use ExUnit.Case
use Mneme

test "skipping all tests does not update code but does exit with an error code" do
# S
auto_assert 2 + 2

auto_assert 2 + 2

auto_assert 1 + 2
end

test "shouldn't run because skip all was used in the first test" do
auto_assert 1 + 1
end
end