Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Pass the srcpath as FQN, test file as testSelector in SBT test events #98

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/scala/scala/tools/partest/nest/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package nest

import java.io.{ Console => _, _ }
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.NANOSECONDS
import scala.collection.mutable.ListBuffer
import scala.concurrent.duration.Duration
Expand Down Expand Up @@ -758,9 +759,10 @@ class SuiteRunner(
// |Java Classpath: ${sys.props("java.class.path")}
}

def onFinishTest(testFile: File, result: TestState): TestState = result
def onFinishTest(testFile: File, result: TestState, durationMs: Long): TestState = result

def runTest(testFile: File): TestState = {
val start = System.nanoTime()
val runner = new Runner(testFile, this, nestUI)

// when option "--failed" is provided execute test only if log
Expand All @@ -778,7 +780,8 @@ class SuiteRunner(
runner.cleanup()
state
}
onFinishTest(testFile, state)
val end = System.nanoTime()
onFinishTest(testFile, state, TimeUnit.NANOSECONDS.toMillis(end - start))
}

def runTestsForFiles(kindFiles: Array[File], kind: String): Array[TestState] = {
Expand Down
10 changes: 6 additions & 4 deletions src/main/scala/scala/tools/partest/sbt/SBTRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class SBTRunner(val config: RunnerSpec.Config,
else l.mkString(" ")
}

private val testSrcPath: String = config.optSourcePath orElse Option(srcDir) getOrElse PartestDefaults.sourcePath

val suiteRunner = new SuiteRunner(
testSourcePath = config.optSourcePath orElse Option(srcDir) getOrElse PartestDefaults.sourcePath,
testSourcePath = testSrcPath,
new FileManager(testClassLoader = testClassLoader),
updateCheck = config.optUpdateCheck,
failed = config.optFailed,
Expand All @@ -66,14 +68,14 @@ class SBTRunner(val config: RunnerSpec.Config,
javaOpts = javaOpts,
scalacOpts = scalacOpts) { self =>

override def onFinishTest(testFile: File, result: TestState): TestState = {
override def onFinishTest(testFile: File, result: TestState, durationMs: Long): TestState = {
self.synchronized {
eventHandler.handle(new Event {
def fullyQualifiedName: String = testFile.testIdent
def fullyQualifiedName: String = scala.tools.partest.nest.PathSettings.testRoot.name + "/" + testSrcPath
def fingerprint: Fingerprint = partestFingerprint
def selector: Selector = new TestSelector(testFile.testIdent)
val (status, throwable) = makeStatus(result)
def duration: Long = -1
def duration: Long = durationMs
})
}
result
Expand Down