improve(core): upgrade trace macro and add custom assert messages - #1579
improve(core): upgrade trace macro and add custom assert messages#1579sqrew wants to merge 1 commit into
Conversation
…support custom messages
| ;; This file verifies the improved 'trace' and 'assert' macros in core/Debug.carp | ||
|
|
||
| (defn main [] | ||
| (let [x (Debug.trace (+ 10 20)) |
There was a problem hiding this comment.
Is the output from these trace calls checked somewhere?
There was a problem hiding this comment.
No, you're probably right that it should be though. I didn't think of that!!
There was a problem hiding this comment.
Should be doable if you add it to the tests that check their output.
There was a problem hiding this comment.
Hey @eriksvedang! I looked into adding the output check to the produces-output/ suite, but I ran into a bit of a snag with how trace resolves paths.
Because the macro uses (file) under the hood, it evaluates to the absolute path of the file at compile time. If I add it to produces-output, the .expected file would need my hardcoded local path (e.g., /home/.../Carp/test/...) and
would instantly fail on GitHub Actions when the CI runner checks it out to a different directory.
I could write a custom shell script to sanitize $PWD from the test output, but since the rest of the test suite cleanly uses execute.sh, I figured it's better to avoid polluting the test harnesses with one-off hacks. Because of this,
the test currently just executes the macro to ensure it compiles and evaluates properly without crashing. Let me know if you'd still prefer me to add a path-sanitizing hack to the test scripts though!
Improves Debug.trace to display the expression text along with its value (using prn formatting), adds custom error message support to global assert via varargs, and removes the redundant/buggy Dynamic.Debug.trace macro.