propcheck
propcheck copied to clipboard
fix: correctly print counter-example for parallel execution
When using parallel execution, the counter-example is a singleton list with a single 2-tuple containing the sequential prefix and the parallel executions. But the code was expecting it to be an enumerable.
1) property broken ticket issuer (PropCheck.Test.BrokenTicketIssuerTest)
test/broken_ticket_issuer_test.exs:8
** (Protocol.UndefinedError) protocol Enumerable not implemented for {[], [[{:set, {:var, 2}, {:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}, {:set, {:var, 3}, {:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}, {:set, {:var, 5}, {:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}], [{:set, {:var, 7}, {:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}, {:set, {:var, 8}, {:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}]]} of type Tuple. This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Range, Stream
code: property "broken ticket issuer", [:verbose] do
stacktrace:
(elixir 1.13.4) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.13.4) lib/enum.ex:143: Enumerable.reduce/3
(elixir 1.13.4) lib/enum.ex:4144: Enum.reduce/3
(propcheck 1.4.2-dev) lib/properties.ex:300: PropCheck.Properties.counter_example_inspect/1
(propcheck 1.4.2-dev) lib/properties.ex:249: PropCheck.Properties.handle_check_results/2
test/broken_ticket_issuer_test.exs:8: (test)
Also, while running a test several times to confirm the fix, another bug was found for the case when the parallel execution counter-example has an empty sequential prefix. In that case, the counter-example was not being classified as a parallel one, and printed incorrectly.
1) property broken ticket issuer (PropCheck.Test.BrokenTicketIssuerTest)
test/broken_ticket_issuer_test.exs:8
Property Elixir.PropCheck.Test.BrokenTicketIssuerTest.property broken ticket issuer() failed. Counter-Example is:
[
{[],
[
[
{:set, {:var, 2},
{:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}},
{:set, {:var, 3},
{:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}},
{:set, {:var, 4},
{:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}},
{:set, {:var, 5},
{:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}
],
[
{:set, {:var, 8},
{:call, PropCheck.Test.BrokenTicketIssuerTest, :inc, []}}
]
]}
]