-
Notifications
You must be signed in to change notification settings - Fork 185
improve(core): upgrade trace macro and add custom assert messages #1579
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
Open
sqrew
wants to merge
2
commits into
carp-lang:master
Choose a base branch
from
sqrew:pr-improve-trace-and-assert
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ;; This file verifies the improved 'trace' and 'assert' macros in core/Debug.carp | ||
|
|
||
| (defn main [] | ||
| (let [x (Debug.trace (+ 10 20)) | ||
| y (Debug.trace @"hello")] | ||
| (do | ||
| (assert (= x 30)) | ||
| (assert (= x 30) "x must be 30") | ||
| ;; Print success message | ||
| (IO.println "All test assertions passed successfully!") | ||
| ()))) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is the output from these trace calls checked somewhere?
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.
No, you're probably right that it should be though. I didn't think of that!!
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.
Should be doable if you add it to the tests that check their output.
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.
will do
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.
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!
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 see. Does setting
file-path-print-lengthtoshortwork in this context?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.
that is exactly the correct way to have solved this. I didn't think of that at all. Nice catch