-
Couldn't load subscription status.
- Fork 1.4k
zio-test: make assert capture expression and source location using macro
#4427
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
assert captures expression and source location using macroassert capture expression and source location using macro
|
@dkarlinsky Great! How does this interrelate with #4242 by @hmemcpy? |
|
It doesn't yet. We talked about it and agreed that I'd rebase on top of @hmemcpy 's PR, once it's merged. |
|
@dkarlinsky @hmemcpy Can we circle up on the two open PRs we have on this? It seems like this PR has a way of capturing the source information that results in fewer changes to the public API. @hmemcpy Does the way the information is being captured here give you the ability to access it and do what you want with it? |
|
I need to take a better look at this, but I think this could work for my case too! It seems to be extracting the location from the tree rather than capturing it in a separate object... Might work! This would mean I'd have to have to change the implementation of I'll experiment with it. Thanks! |
|
I want to give it a try your way, capture the |
|
@dkarlinsky You've definitely tackled it slightly different ways but are trying to address similar goals. Anyway, I think the approach suggested by @hmemcpy makes sense. |
|
So good news - it indeed works! I was able to capture the location info of the This means that similarly to I'd still like to put my changes in next, are you close to finishing the PR, @dkarlinsky? |
Just need to fix all the broken testis in |
|
I think if you keep just the filename, IntelliJ will be smart enough to hyperlink it anyway. Not sure this would work for the console output. But I agree, relative path to the source would be better. |
Didn't work for me in console output - if it's just the file name, no hyperlink :( |
ignoring line numbers in test output - otherwise the tests get too brittle.
baebdd3 to
051cd77
Compare
|
Hallelujah 🤣 |
Yay! Finally! 😅 |
|
@adamgfraser would love if you could take a look. |
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 think this looks really good!
For the rendering of the results, right now we're also labeling the assert with the left hand side of the assertion. Do you think that is necessary or maybe we can just render the line of the failing test as a new line? Just wondering if it could be confusing if users can add their own labeling and now we are adding this labeling? Also happy to address the rendering in a follow up PR.
@adamgfraser |
|
@dkarlinsky Sounds good to me! |
…macro (zio#4427) * zio-test|assert captures expression and source location using macro * prepend `_root_` in macros; fix; fmt * rename `zio.test.assertRuntime` to `assertImpl` and made it package private * DefaultTestReporterSpec passes for 2.x and dotty * fixing line numbers after fix and fmt * fixed ZTestFrameworkSpec; ignoring line numbers in test output - otherwise the tests get too brittle. * fixed SummaryBuilderSpec * fixed MavenJunitSpec * fix + fmt * fixing fatal "unused import" in 2.13 * dropping lihaoyi sourcecode dependency in favor of small local macro * fixing ZTestFrameworkSpec for scala 3 * fix linesIterator deprecation in 2.11
Most tests verifying assert output are failing and need to be fixed.