-
Notifications
You must be signed in to change notification settings - Fork 25
improvement: Add location to failure to help mark it in VS Code #834
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ private class ClassEntryLookUp( | |
sourceUriToSourceFile: Map[SourceFileKey, SourceFile], | ||
sourceUriToClassFiles: Map[SourceFileKey, Seq[ClassFile]], | ||
classNameToSourceFile: Map[String, SourceFile], | ||
sourceNameToSourceFile: Map[String, Seq[SourceFile]], | ||
missingSourceFileClassFiles: Seq[ClassFile], | ||
val orphanClassFiles: Seq[ClassFile], | ||
logger: Logger | ||
|
@@ -50,6 +51,10 @@ private class ClassEntryLookUp( | |
missingSourceFileClassFiles.map(_.fullyQualifiedName) | ||
} | ||
|
||
def uriFromFilename(filename: String): Option[URI] = { | ||
sourceNameToSourceFile.get(filename).flatMap(_.headOption).map(_.uri) | ||
} | ||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need this new method. You should be able to use |
||
|
||
def classesByScalaName: Map[String, Iterable[String]] = | ||
fullyQualifiedNames.groupBy[String](NameTransformer.scalaClassName) | ||
|
||
|
@@ -257,6 +262,7 @@ private object ClassEntryLookUp { | |
sourceUriToSourceFile, | ||
sourceUriToClassFiles.toMap, | ||
classNameToSourceFile.toMap, | ||
sourceNameToSourceFile, | ||
missingSourceFileClassFiles.toSeq, | ||
orphanClassFiles.toSeq, | ||
logger | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package ch.epfl.scala.debugadapter.testing | |
|
||
import sbt.testing.Status | ||
import scala.jdk.CollectionConverters.* | ||
import ch.epfl.scala.debugadapter.internal.SourceLookUpProvider | ||
|
||
trait TestSuiteEventHandler { | ||
def handle(testSuiteEvent: TestSuiteEvent): Unit | ||
|
@@ -25,7 +26,8 @@ object TestSuiteEventHandler { | |
* Provide a summary of test suite execution based on passed TestSuiteEvent.Results parameter. | ||
*/ | ||
def summarizeResults( | ||
testSuiteResult: TestSuiteEvent.Results | ||
testSuiteResult: TestSuiteEvent.Results, | ||
sourceLookUpProviderOpt: Option[SourceLookUpProvider] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bloop will not be able to provide this, so this becomes again more difficult. We could make it all public, but then it becomes a bit unmanagable without a a large refactor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure to understand why Bloop could not provide an instance of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need to reimplement it in Bloop, or make SourceLookUpProvider not private. |
||
): TestSuiteSummary = { | ||
val results = testSuiteResult.events.map { e => | ||
val name = TestUtils.printSelector(e.selector).getOrElse("") | ||
|
@@ -35,13 +37,24 @@ object TestSuiteEventHandler { | |
case Status.Failure => | ||
val failedMsg = | ||
TestUtils.printThrowable(e.throwable()).getOrElse("") | ||
val location = if (e.throwable().isDefined()) { | ||
val throwable = e.throwable().get.getStackTrace().headOption | ||
for { | ||
stackElement <- throwable | ||
sourceLookUpProvider <- sourceLookUpProviderOpt | ||
uri <- sourceLookUpProvider.getSourceFileURI(stackElement.getFileName()) | ||
} yield new SingleTestResult.Location(uri.toString(), stackElement.getLineNumber()) | ||
|
||
} else { | ||
None | ||
} | ||
val formatted = | ||
TestSuiteEventHandler.formatError( | ||
name, | ||
failedMsg, | ||
indentSize = 0 | ||
) | ||
SingleTestResult.Failed(name, e.duration, formatted) | ||
SingleTestResult.Failed(name, e.duration, formatted, location) | ||
case _ => | ||
SingleTestResult.Skipped(name) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ private[debugadapter] final class TestSuitesDebuggee( | |
s"${getClass.getSimpleName}(${target.uri}, [${tests.mkString(", ")}])" | ||
|
||
override def run(listener: DebuggeeListener): CancelableFuture[Unit] = { | ||
val eventHandler = new SbtTestSuiteEventHandler(listener) | ||
val eventHandler = new SbtTestSuiteEventHandler(listener, () => sourceLookUpProvider) | ||
|
||
Comment on lines
70
to
72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really hacky. It would be clearer to pass the override def run(listener: DebuggeeListener, sourceLookup: SourceLookupProvider): CancelableFuture[Unit] = {
val eventHandler = new SbtTestSuiteEventHandler(listener, sourceLookup)
???
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I remember that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about the other PR then? Might be simpler for us to calculate it in Metals |
||
@annotation.tailrec | ||
def receiveLogs(is: ObjectInputStream, os: ObjectOutputStream): Unit = { | ||
|
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 gets a bit hacky unfortunately, so not sure if we want to go that way. Alternatively, we could just add the name and resolve it in metals when forwarding the event.
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 it should not be a
var
but a normal parameter in therun
method.