-
Notifications
You must be signed in to change notification settings - Fork 222
Automated testing for examples in README.md #1203
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
Conversation
The main version doesn't support leading comment chars yet
6af26e7
to
f2f0f38
Compare
Rewriting some of the examples to support test-doc-blocks library =prints=> has been replaced with =stdout=> because that generates actual tests for what it prints out
.github/workflows/clojure.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add this to the other tests, since test-doc-blocks requires clojure 1.11. I also don't think at this point testing with the whole matrix of clojure versions is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this file were required to make the comment blocks compatible with test-doc-blocks. I also found several small discrepancies between expected results and what it actually does. Some syntax errors as well.
@@ -368,17 +373,18 @@ Example of a multi-arity function with instrumentation scopes and custom reporti | |||
([x y] (* x y))))) | |||
|
|||
(multi-arity-pow 4) | |||
; =prints=> :malli.core/invalid-output {:output [:int {:max 6}], :value 16, :args [4], :schema [:=> [:cat :int] [:int {:max 6}]]} | |||
; => 16 | |||
;; =stdout=> :malli.core/invalid-output {:output [:int {:max 6}], :value 16, :args [4], :schema [:=> [:cat :int] [:int {:max 6}]]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of leveraging test-doc-blocks' capability of verifying what it printed in stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some suggestions tho
I missed this block as the upper expression can't be tested like this. It returns a reified object which you can't test equality for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
This PR adds an automated test step which generates Clojure tests from most of the examples in the documentation and runs them to see if they still work. It uses https://github.com/lread/test-doc-blocks to do the testing.
We have over two hundred examples in the readmes and these can be verified with test-doc-blocks. The syntax is very similar to what we are already using to document the correct usage and the result it produces in the REPL. Think:
Pros
Cons