Skip to content

Add debug mode #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 10, 2024
Merged

Add debug mode #91

merged 5 commits into from
Dec 10, 2024

Conversation

paintparty
Copy link
Contributor

@paintparty paintparty commented Nov 12, 2024

Hi!

Thanks for making test-refresh, great library!

I use test-refresh, as intended, to automatically run tests in projects that I'm working on.

Over time, I found that more often I would use test-refresh as a hot-reloading system when working in JVM Clojure. This means I would temporarily disable all tests and just call a single public function in my project so that I can observe the execution at different points using tapping/debugging macros from Fireworks that print and return forms. You can get a sense of what this looks like by checking out the screen recording below. It shows test-refresh running in an integrated editor terminal, with the the editor's auto-save-with-delay automatically triggering the reloads. Just to be clear, this kind of hot-reloading workflow does not depend on Fireworks - it is achievable with similar libs such as playback, debux, hashp, telemere, ken, spyscope, omni-trace, postmortem, sayid, or the user's own hand-rolled debugging or tapping functions/macros:

fw-tour-intro-light

My global profile definded in ~/.lein/profiles.clj:

 {:user {:dependencies [[pjstadig/humane-test-output "0.11.0"]]
        :injections [(require 'pjstadig.humane-test-output)
                     (pjstadig.humane-test-output/activate!)]
        :plugins [[com.jakemccrary/lein-test-refresh "0.5.5"]]
        :test-refresh {:quiet             true
                       :changes-only      true
                       :notify-on-success false

                       ;; New options:
                       
                       ;; Uncomment next 2 lines for debug mode
                       ;; Comment them out if you want to run tests
                       :debug             true
                       :banner            "🔥"

                       ;; Uncomment next line for custom banner in testing mode
                       ;; :banner             "📋 Running tests..."

                       ;; This clears the console between reloads, preserving scrollback
                       :clear             true
                       }}}

The 3 options that I added to enable this workflow:

:debug - Disables all tests and reporting. Surfaces errors. Defaults to false

:banner - Allows user to supply their own banner. This can be used both in :debug mode as well as the normal default test running mode. You can supply an empty string to disable banner printing. If not supplied, current test-refresh banner with stars is used.

:clear - Clears the terminal in between reloads, preserving scrollback. When :debug is set to true, this is enabled by default. Defaults to false, so user must opt-in to this feature when running tests.


Testing:

I've tested the :clear feature on MacOS 12.6 with the following terminal emulators:

Emulator Clears? Preserves Scrollback?
iTerm
Alacritty
Terminal
Warp
Kitty ×
WezTerm ×

And the following editor-integrated terminal emulators:

Editor Clears? Preserves Scrollback?
Intellij IDEA
VSCode
SublimeText (w Terminus)
Neovim (VT220/xterm) ×
Emacs (ansi-term) ×
Emacs (eshell) × ×

I haven't tested the :clear feature on linux but would expected similar results as above.

I wouldn't expect the :clear feature to work on windows, but I think that could be easily added in the future.

@jakemcc
Copy link
Owner

jakemcc commented Nov 12, 2024 via email

@paintparty
Copy link
Contributor Author

Thanks for the prompt reply. No rush at all. Look forward to hearing your thoughts after you get a chance to check it out.

@jakemcc
Copy link
Owner

jakemcc commented Dec 1, 2024

Sorry for the delay, this holiday season has sucked up more of my open-source time than I thought it would.

I've taken a quick look and I think it is looking good, though I'm still planning on taking a deeper look and actually run it before merging. I'm hopeful that will happen either this week or next.

Thanks for the contribution. Looking forward to getting it in.

@paintparty
Copy link
Contributor Author

Thanks for the update @jakemcc!

@jakemcc
Copy link
Owner

jakemcc commented Dec 10, 2024

Seems mostly good to me, though it removes the default banner from the deps.edn code path since the resolving happens in a leiningen specific code path. This could be fixed by moving that code that does the defaulting over to the shared code.

I'll merge and fix that. Thank you for the contribution

@jakemcc jakemcc merged commit 234aaa4 into jakemcc:master Dec 10, 2024
@jakemcc
Copy link
Owner

jakemcc commented Dec 15, 2024

Released as 0.26.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants