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

Commit d8c59ed

Browse files
authored
Merge pull request #98 from retronym/topic/selector
Pass the srcpath as FQN, test file as testSelector in SBT test events
2 parents 6544f9d + 1efc163 commit d8c59ed

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/main/scala/scala/tools/partest/nest/Runner.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package nest
77

88
import java.io.{ Console => _, _ }
99
import java.util.concurrent.Executors
10+
import java.util.concurrent.TimeUnit
1011
import java.util.concurrent.TimeUnit.NANOSECONDS
1112
import scala.collection.mutable.ListBuffer
1213
import scala.concurrent.duration.Duration
@@ -758,9 +759,10 @@ class SuiteRunner(
758759
// |Java Classpath: ${sys.props("java.class.path")}
759760
}
760761

761-
def onFinishTest(testFile: File, result: TestState): TestState = result
762+
def onFinishTest(testFile: File, result: TestState, durationMs: Long): TestState = result
762763

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

766768
// when option "--failed" is provided execute test only if log
@@ -778,7 +780,8 @@ class SuiteRunner(
778780
runner.cleanup()
779781
state
780782
}
781-
onFinishTest(testFile, state)
783+
val end = System.nanoTime()
784+
onFinishTest(testFile, state, TimeUnit.NANOSECONDS.toMillis(end - start))
782785
}
783786

784787
def runTestsForFiles(kindFiles: Array[File], kind: String): Array[TestState] = {

src/main/scala/scala/tools/partest/sbt/SBTRunner.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ class SBTRunner(val config: RunnerSpec.Config,
5454
else l.mkString(" ")
5555
}
5656

57+
private val testSrcPath: String = config.optSourcePath orElse Option(srcDir) getOrElse PartestDefaults.sourcePath
58+
5759
val suiteRunner = new SuiteRunner(
58-
testSourcePath = config.optSourcePath orElse Option(srcDir) getOrElse PartestDefaults.sourcePath,
60+
testSourcePath = testSrcPath,
5961
new FileManager(testClassLoader = testClassLoader),
6062
updateCheck = config.optUpdateCheck,
6163
failed = config.optFailed,
@@ -66,14 +68,14 @@ class SBTRunner(val config: RunnerSpec.Config,
6668
javaOpts = javaOpts,
6769
scalacOpts = scalacOpts) { self =>
6870

69-
override def onFinishTest(testFile: File, result: TestState): TestState = {
71+
override def onFinishTest(testFile: File, result: TestState, durationMs: Long): TestState = {
7072
self.synchronized {
7173
eventHandler.handle(new Event {
72-
def fullyQualifiedName: String = testFile.testIdent
74+
def fullyQualifiedName: String = scala.tools.partest.nest.PathSettings.testRoot.name + "/" + testSrcPath
7375
def fingerprint: Fingerprint = partestFingerprint
7476
def selector: Selector = new TestSelector(testFile.testIdent)
7577
val (status, throwable) = makeStatus(result)
76-
def duration: Long = -1
78+
def duration: Long = durationMs
7779
})
7880
}
7981
result

0 commit comments

Comments
 (0)