Skip to content

Instantly share code, notes, and snippets.

@thumbnail
Last active June 2, 2020 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thumbnail/2f31edcda5ec19e5af75374024f0152b to your computer and use it in GitHub Desktop.
Save thumbnail/2f31edcda5ec19e5af75374024f0152b to your computer and use it in GitHub Desktop.
disable ansi colors matcher-combinators cursive
;; cursives popup with test-failure information doesn't support ansi.
;; adding this profile to your profiles.clj surpresses ansi colors from poluting the popup
{ :matcher-combinators {:dependencies [[nubank/matcher-combinators "1.2.7"]]
:injections [(try
(require '[matcher-combinators.printer])
(catch java.io.FileNotFoundException _ nil))
(alter-var-root #'matcher-combinators.printer/colorized-print
(fn [f] ;; disable ansi support
(fn colorized-print [{:keys [expression]}]
(clojure.pprint/write-out expression))))]}}
@thumbnail
Copy link
Author

 :matcher-combinators {:dependencies [[nubank/matcher-combinators "1.5.1"]]
                       :injections [(try
                                     (require '[matcher-combinators.printer])
                                     (catch java.io.FileNotFoundException _ nil))
                                    (alter-var-root #'matcher-combinators.printer/colorized-print
                                     (fn [f] ;; disable ansi support
                                      (fn colorized-print [{:keys [expression] :as args}]
                                        ;; if do-report is redefined, we're in cursive, and don't want to pretty print
                                        (if (= clojure.test$do_report (.getClass (.getRawRoot #'clojure.test/do-report)))
                                         (f args)
                                         (clojure.pprint/write-out expression)))))]}

This alteration makes sure to disable ansi colors only inside a cursive test,keeping the colors otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment