Skip to content

Commit 7d5ebe6

Browse files
authored
locate the classes directory reliably
the old code would fail with e.g. > ++2.12.5-bin-76f588e-SNAPSHOT > testOnly *WarningsSpec this was showing up repeatedly when running the Scala community build against as-yet-unmerged scala/scala PRs
1 parent d4a72ac commit 7d5ebe6

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/test/scala/scala/async/package.scala

+9-17
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,15 @@ package object async {
6363
new Global(settings, reporter)
6464
}
6565

66-
def scalaBinaryVersion: String = {
67-
val PreReleasePattern = """.*-(M|RC|pre-).*""".r
68-
val Pattern = """(\d+\.\d+)\..*""".r
69-
val SnapshotPattern = """(\d+\.\d+\.\d+)-\d+-\d+-.*""".r
70-
scala.util.Properties.versionNumberString match {
71-
case s @ PreReleasePattern(_) => s
72-
case SnapshotPattern(v) => v + "-SNAPSHOT"
73-
case Pattern(v) => v
74-
case _ => ""
75-
}
76-
}
77-
78-
def toolboxClasspath = {
79-
val f = new java.io.File(s"target/scala-${scalaBinaryVersion}/classes")
80-
if (!f.exists) sys.error(s"output directory ${f.getAbsolutePath} does not exist.")
81-
f.getAbsolutePath
82-
}
66+
// returns e.g. target/scala-2.12/classes
67+
// implementation is kludgy, but it's just test code. Scala version number formats and their
68+
// relation to Scala binary versions are too diverse to attempt to do that mapping ourselves here,
69+
// as we learned from experience. and we could use sbt-buildinfo to have sbt tell us, but that
70+
// complicates the build since it does source generation (which may e.g. confuse IntelliJ).
71+
// so this is, uh, fine? (crosses fingers)
72+
def toolboxClasspath =
73+
new java.io.File(this.getClass.getProtectionDomain.getCodeSource.getLocation.toURI)
74+
.getParentFile.getParentFile
8375

8476
def expectError(errorSnippet: String, compileOptions: String = "",
8577
baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String) {

0 commit comments

Comments
 (0)