mindreframer

mindreframer

@zachallaun WOW! I’ve tried it and now it feels buttery smooth! “Definitely worth pursuing”, as you’ve said. I think it’s ready to be tried out on real codebases.

Would you be open to a PR, that restarts Mneme.Server on each Mneme.start() call? I run my tests interactively in IEx and currently the call the Mneme.start() from the test_helper.exs fails on 2nd run and restarts the whole IEx process. This is the commit that implements it: https://github.com/mindreframer/mneme/commit/4c17f0360f2b6dea497a2878d252dfbae7347749
Also there are probably cleaner ways to do it :slight_smile:

0
Post #11
zachallaun

zachallaun OP

Definitely open to it or something like it, possibly behind an option to Mneme.start(). I need to put a bit more thought into how Mneme should be started anyways — right now it’s sort of just “simplest thing that works”.

0
Post #12
zachallaun

zachallaun OP

@mindreframer I just pushed a change to main that adds a :restart option. When you have a moment, would you mind trying it out and seeing if it does the trick?

# test_helper.exs
ExUnit.start()
Mneme.start(restart: true)
1
Post #13
mindreframer

mindreframer

@zachallaun P-E-R-F-E-C-T! I’ve tried it and it “JUST WORKS”.
Thanks for this package, looking forward to work with it on some real code.

You’ve made my day! Thanks for the awesome “customer support” experience, it was really fun! I hope you’ll enjoy using mnene as much as I will :grin:
Have a nice day!

1
Post #14
zachallaun

zachallaun OP

Thanks so much for the kind words! Please let me know if you have any more feedback as you use it. In particular, if you ever find that the patterns being generated aren’t useful, please open an issue!

Edit: Released v0.1.2 to include that :restart option. :slightly_smiling_face:

0
Post #15
tcoopman

tcoopman

I just wanted to let you know that I’ve just tried using the tool and it’s awesome! Love it so far!!

1
Post #16
zachallaun

zachallaun OP

Thank you so much for the kind words, @tcoopman!

I’m hoping to record a slightly longer screencast soon showing off some workflows that this enables. One I’ve been really enjoying is a kind of variant of REPL-driven development, where I have a pane open with a set of example calls to a function I’m working on using the @mneme action: :accept option to auto-accept changes. So as I work on it, I can just use a single keybinding and see all the calls update with whatever it’s currently returning.

@mneme action: :accept
test "wip" do
  auto_assert some_function(args1...)

  auto_assert some_function(args2...)

  auto_assert some_function(args3...)

  auto_assert some_function(args4...)
end

Then once everything is as I expect, I remove the @mneme action: :accept and refactor into more organized/useful tests.

Edit: I actually just ran into some difficulty with this because Mneme selects the simplest pattern by default, so if you are doing the above with a function that returns a map, it’ll generate a %{} pattern, which doesn’t give you much information. I’ve just pushed a new :default_pattern option that can be used to specify which pattern should be selected:

@mneme action: :accept, default_pattern: :last
test "wip" do
  ...
end
1
Post #17
Sebb

Sebb

:star_struck: this. is. amazing.

1
Post #18
zachallaun

zachallaun OP

Thanks to everyone who’s tried this out so far. There have been several patch releases since I initially posted. Currently on v0.1.5, but all changes since v0.1.0 summarized below:

Enhancements

  • Dramatically reduce the performance gap between auto_assert and ExUnit’s assert.

  • Add a :restart option to Mneme.start/1 to restart Mneme if called multiple times.

  • Add a :default_pattern configuration option for auto-assertions which controls the pattern that should be selected by default when prompted.

  • More consistent handling of charlists: lists of integers will now generate themselves as a pattern as well as a charlist if the list is ASCII printable (#6).

Fixes

  • When converting an auto-assertion to an ExUnit assertion, select the identical pattern when the :default_pattern is :infer (set by default).

  • Fix a bug that could cause auto_assert expressions to revert to the previous value when using Mneme.start(restart: true) (#7).

2
Post #19
zachallaun

zachallaun OP

Getting closer to the next sizable update to Mneme and wanted to share! After noticing that it can sometimes be difficult to visually parse what changed when an auto-generated value updates, I started working on semantic diffing, using the amazing Difftastic as reference and inspiration.

This has proved more of a rabbit hole than I initially thought, but is still relatively easy thanks to Elixir’s general awesomeness. Today I reached the point where my semantic diff development branch can start using semantic diffs to work on semantic diffs!

For instance, here’s what an update might look like using the latest release:

image (1)
image (1)700×454 21.5 KB

Here’s the same update using semantic diffs:

image
image626×443 22.1 KB

There’s still a ways to go before this lands, but I’m hoping that being able to use semantic diffs in development will help expose edge-cases/etc. before I ship the feature.

8
Post #20