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
StackDepthException.failedCodeStackDepth returns invalid value 0
when using Future + passing custom implicit position
#2286
Comments
…ng StackDepthException #SCL-21627 fixed See scalatest/scalatest#2286 for the details. It's better not to show any class name at all than to show a wrong one (`Assertions`). Navigation will still work based on the file name. However, we don't have a file path, we only have a short file name. When we have multiple files with the same name, IDEA will show a chooser tooltip so the user can manually choose which file to open
…ng StackDepthException #SCL-21627 fixed See scalatest/scalatest#2286 for the details. It's better not to show any class name at all than to show a wrong one (`Assertions`). Navigation will still work based on the file name. However, we don't have a file path, we only have a short file name. When we have multiple files with the same name, IDEA will show a chooser tooltip so the user can manually choose which file to open
@unkarjedy @mutcianm @bvenners hmm, unfortunately unless we do the stack trace look up at the point of the Position is created, we can't refer back to the stack trace of the passed Position where it is created. Theoretically, we can either compute the stack depth at the point of the creation of the Position, or, we save the stack trace along in the Position, but both are very expensive thing to do, I think. I wonder if intellij can use the Position directly when it is available? |
The position only contains the file name, not the file path. scalatest/jvm/scalactic-macro/src/main/resources/org/scalactic/ScalacticBundle.properties Line 60 in 972b4d3
Not sure if we should silently add it during the compilation. For now I am using the solution described in JetBrains/intellij-scala@b63f204
|
I think we might close this then |
Why is SCALACTIC_FILL_FILE_PATHNAMES not the default, and why can it only be set as an environment variable? |
Run the test below.
It contains 4 failed tests.
tests.scala
The output is as follows:
Notice that in the
"test BAD 1"
it fails to detectfailedCodeStackDepth
and returns 0 instead.Future { }
introduces an asynchronous boundary, and parameterimplicit pos: Position
holds a line which is different from the line insideFuture {}
. Due to this in this place org.scalatest.exceptions.StackDepthExceptionHelper#getStackDepth it can't find a stack trace element with the same line number as inpos
, because insideFuture { }
async boundary, the line number is different.This issue leads to an issue in IntelliJ Scala Plugin, where we rely on the value of
failedCodeStackDepth
https://youtrack.jetbrains.com/issue/SCL-21627/clicking-on-a-hyperlink-in-a-StackTrace-of-a-failed-test-navigates-to-a-wrong-file-Assertions.scala
In theory, in such case we could just pick the line with matching only the file name and not the line.
Test
"test BAD 2"
is similar, but in this case we can't do this trick because stacktrace doesn't contain the original file name with the testsThe text was updated successfully, but these errors were encountered: