Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test for stack frame source path validation
- Loading branch information
1 parent
3d687ee
commit 343e4b0
Showing
6 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
76 changes: 76 additions & 0 deletions
76
...cala-ide.sdt.debug.tests/src/org/scalaide/debug/internal/SourcePathInStackFrameTest.scala
This file contains 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,76 @@ | ||
package org.scalaide.debug.internal | ||
|
||
import java.io.File | ||
|
||
import org.eclipse.core.resources.IncrementalProjectBuilder | ||
import org.eclipse.core.runtime.NullProgressMonitor | ||
import org.junit.After | ||
import org.junit.AfterClass | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.scalaide.core.testsetup.SDTTestUtils | ||
import org.scalaide.core.testsetup.TestProjectSetup | ||
|
||
object SourcePathInStackFrameTest extends TestProjectSetup("source-path", bundleName = "org.scala-ide.sdt.debug.tests") with ScalaDebugRunningTest { | ||
final val BP_TYPENAME = "test.a.Main" | ||
|
||
var initialized = false | ||
|
||
def initDebugSession(launchConfigurationName: String): ScalaDebugTestSession = ScalaDebugTestSession(file(launchConfigurationName + ".launch")) | ||
|
||
@AfterClass | ||
def deleteProject(): Unit = { | ||
SDTTestUtils.deleteProjects(project) | ||
} | ||
} | ||
|
||
class SourcePathInStackFrameTest { | ||
import SourcePathInStackFrameTest._ | ||
|
||
var session: ScalaDebugTestSession = null | ||
|
||
@Before | ||
def initializeTests(): Unit = { | ||
SDTTestUtils.enableAutoBuild(false) | ||
if (!initialized) { | ||
project.underlying.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor) | ||
project.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor) | ||
initialized = true | ||
} | ||
} | ||
|
||
@After | ||
def cleanDebugSession(): Unit = { | ||
if (session ne null) { | ||
session.terminate() | ||
session = null | ||
} | ||
} | ||
|
||
private val mainBreakpoint = 16 | ||
private val expectedSourcePath = File.separator + "test" + File.separator + "SourcePath.scala" | ||
@Test | ||
def simpleCheckForSourcePathInTopMostStackFrameForClassesWithPkgsWhichDontReflectSourceFoldersStruct(): Unit = { | ||
session = initDebugSession("SourcePath") | ||
session.runToLine(BP_TYPENAME, mainBreakpoint) | ||
Assert.assertTrue(session.currentStackFrame.getSourcePath == expectedSourcePath) | ||
|
||
val bp4 = session.addLineBreakpoint("test.b.B", 4) | ||
val bp8 = session.addLineBreakpoint("test.b.c.C", 8) | ||
try { | ||
session.waitForBreakpointsToBeEnabled(bp4, bp8) | ||
|
||
session.resumeToSuspension() | ||
Assert.assertTrue(session.currentStackFrame.getSourcePath == expectedSourcePath) | ||
|
||
session.resumeToSuspension() | ||
Assert.assertTrue(session.currentStackFrame.getSourcePath == expectedSourcePath) | ||
|
||
session.resumeToCompletion() | ||
} finally { | ||
bp4.delete() | ||
bp8.delete() | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
org.scala-ide.sdt.debug.tests/test-workspace/source-path/.classpath
This file contains 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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
18 changes: 18 additions & 0 deletions
18
org.scala-ide.sdt.debug.tests/test-workspace/source-path/.project
This file contains 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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>source-path</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
15 changes: 15 additions & 0 deletions
15
org.scala-ide.sdt.debug.tests/test-workspace/source-path/SourcePath.launch
This file contains 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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<launchConfiguration type="scala.application"> | ||
<stringAttribute key="bad_container_name" value="/source-path/f"/> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> | ||
<listEntry value="/source-path/src/test/SourcePath.scala"/> | ||
</listAttribute> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> | ||
<listEntry value="1"/> | ||
</listAttribute> | ||
<mapAttribute key="org.eclipse.debug.core.preferred_launchers"> | ||
<mapEntry key="[debug]" value="scala.application.new"/> | ||
</mapAttribute> | ||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="test.a.Main"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="source-path"/> | ||
</launchConfiguration> |
21 changes: 21 additions & 0 deletions
21
org.scala-ide.sdt.debug.tests/test-workspace/source-path/src/test/SourcePath.scala
This file contains 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,21 @@ | ||
package test { | ||
package b { | ||
class B { | ||
def foo = 5 | ||
} | ||
package c { | ||
trait C { | ||
def bar = 7 | ||
} | ||
} | ||
} | ||
package a { | ||
import test.b.c.C | ||
object Main extends App with C { | ||
import test.b.B | ||
val b = new B | ||
println(b.foo) | ||
println(bar) | ||
} | ||
} | ||
} |