zachallaun / mneme

Snapshot testing for Elixir
https://hex.pm/packages/mneme
100 stars 5 forks source link

Bug when starting iex -S mix with MIX_ENV = test #20

Closed mindreframer closed 1 year ago

mindreframer commented 1 year ago

Reproduction here:

Cheers, and have a good Saturday!

mindreframer commented 1 year ago

When I comment out mneme from mix.exs, this error goes away, so I assume it is somehow related to mneme.

zachallaun commented 1 year ago

Thanks for the report and the reproduction repo!

Unfortunately I'm not able to reproduce this using that repo on Elixir 1.14.2-otp-25, 1.14.2/otp-25.3, or 1.14.3/otp-25.3.

Could you please try the following and let me know if any of them work?

  1. Run MIX_ENV=test mix deps.compile --force and check if the problem persists.
  2. Replace the :mneme dependency with {:mneme, github: "zachallaun/mneme", ref: "remove-dbg"} and check whether the issue persists.
mindreframer commented 1 year ago

@zachallaun Hey, thanks!

I tried your suggestions.

  1. did not change anyting
  2. this worked! But I have noticed, that re-running my IEx session based ExUnit tests multiple times fails with the following error:
TestIex.run
** (ArgumentError) errors were found at the given arguments:

  * 1st argument: table name already exists

    (stdlib 4.2) :ets.new(:__mneme_options_cache__, [:named_table, :public])
    (mneme 0.2.2) lib/mneme/options.ex:100: Mneme.Options.configure/0
    (mneme 0.2.2) lib/mneme.ex:127: Mneme.start/1
    /Users/roman/Desktop/work/sandbox/0.elixir/virtfs/test/test_helper.exs:1: (file)
    iex:2: (file)

I guess you're starting an ETS table without checking, if it's already started. That one should have an easy fix. Should I make an issues for it?

Best, Roman

zachallaun commented 1 year ago

Thanks for checking, Roman!

No need to start an issue re: the ETS table, I'll fix that as well. :) Expect a small release shortly!

mindreframer commented 1 year ago

Great, thank you a lot! I enjoy using Mneme a lot! In a recent crawler project Mneme in combination with

use Mneme, action: :accept, default_pattern: :last

was awesome for updating big assertions in a blink! Big thank you!

zachallaun commented 1 year ago

Thank you so much for saying so! That's awesome to hear! 😄

zachallaun commented 1 year ago

@mindreframer Both issues should be fixed in v0.2.3 🙂

mindreframer commented 1 year ago

Bam! That's crazy speed from report to fix! And this on Saturday. Unbelievable. Thanks again and consider me very-very impressed. You should write a blog post about Mneme, you're doing lots of interesting things in the code base. It's a treasure of cool tricks. Really impressive.

Have a great weekend!

zachallaun commented 1 year ago

@mindreframer Thank you so much for the kind words! I really, really appreciate it.

I'm hoping to write more about what I've learned working on this and highlight the bits I'm most proud of at some point soon.