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

Commit 1c78ce6

Browse files
committed
Locate partest-javaagent in classpath
It used to be searched in ./build but that doesn’t work for the sbt build, where it is actually under ./build-sbt. The correct path is already on the partest classpath, so we can simply pull it from there with `findArtifact` instead of using `findJar`. Some other obsolete uses of `findJar` along with `buildPackLibDir` are also removed.
1 parent 10f9080 commit 1c78ce6

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class FileManager(val testClassLoader: URLClassLoader) {
111111
lazy val libraryUnderTest: Path = findArtifact("library")
112112
lazy val reflectUnderTest: Path = findArtifact("reflect")
113113
lazy val compilerUnderTest: Path = findArtifact("compiler")
114+
lazy val agentLib: Path = findArtifact("javaagent")
114115

115116
lazy val testClassPath = testClassLoader.getURLs().map(url => Path(new File(url.toURI))).toList
116117

@@ -126,13 +127,14 @@ class FileManager(val testClassLoader: URLClassLoader) {
126127
else "installed"
127128
}
128129

129-
// find library/reflect/compiler jar or subdir under build/$stage/classes/
130+
// find library/reflect/compiler/javaagent jar or subdir under build/$stage/classes/
130131
private def findArtifact(name: String): Path = {
131132
val canaryClass =
132133
name match {
133-
case "library" => Class.forName("scala.Unit", false, testClassLoader)
134-
case "reflect" => Class.forName("scala.reflect.api.Symbols", false, testClassLoader)
135-
case "compiler" => Class.forName("scala.tools.nsc.Main", false, testClassLoader)
134+
case "library" => Class.forName("scala.Unit", false, testClassLoader)
135+
case "reflect" => Class.forName("scala.reflect.api.Symbols", false, testClassLoader)
136+
case "compiler" => Class.forName("scala.tools.nsc.Main", false, testClassLoader)
137+
case "javaagent" => Class.forName("scala.tools.partest.javaagent.ProfilingAgent", false, testClassLoader)
136138
}
137139

138140
val path = Path(canaryClass.getProtectionDomain.getCodeSource.getLocation.getPath)

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ object PathSettings {
4242
// Directory <root>/test/files or .../scaladoc
4343
def srcDir = Directory(testRoot / testSourcePath toCanonical)
4444

45-
// Directory <root>/build/pack/lib
46-
private def buildPackLibDir = Directory(buildDir / "pack" / "lib")
47-
4845
// Directory <root>/test/files/lib
4946
private def srcLibDir = Directory(srcDir / "lib")
5047

@@ -60,8 +57,4 @@ object PathSettings {
6057

6158
def srcSpecLib = findJar("instrumented", Directory(srcDir / "speclib"))
6259
def srcCodeLib = findJar("code", Directory(srcDir / "codelib"), Directory(testRoot / "files" / "codelib") /* work with --srcpath pending */)
63-
def agentLib = findJar("scala-partest-javaagent", buildPackLibDir)
64-
def scalaCheck = findJar("scalacheck", buildPackLibDir, srcLibDir)
65-
def testInterface = findJar("test-interface", buildPackLibDir, srcLibDir)
66-
def diffUtils = findJar("diffutils", buildPackLibDir)
6760
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
551551
case _ => Nil
552552
}
553553
def extraJavaOptions = kind match {
554-
case "instrumented" => ("-javaagent:"+PathSettings.agentLib.fold(sys.error, identity)).split(' ')
554+
case "instrumented" => ("-javaagent:"+agentLib).split(' ')
555555
case _ => Array.empty[String]
556556
}
557557

0 commit comments

Comments
 (0)