From 7d5ebe62336ab99a5988d4ef472fd486ec6cbe49 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 5 Mar 2018 19:47:07 -0800 Subject: 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 --- src/test/scala/scala/async/package.scala | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/test/scala/scala/async/package.scala b/src/test/scala/scala/async/package.scala index 5c4e943..94a26f9 100644 --- a/src/test/scala/scala/async/package.scala +++ b/src/test/scala/scala/async/package.scala @@ -63,23 +63,15 @@ package object async { new Global(settings, reporter) } - def scalaBinaryVersion: String = { - val PreReleasePattern = """.*-(M|RC|pre-).*""".r - val Pattern = """(\d+\.\d+)\..*""".r - val SnapshotPattern = """(\d+\.\d+\.\d+)-\d+-\d+-.*""".r - scala.util.Properties.versionNumberString match { - case s @ PreReleasePattern(_) => s - case SnapshotPattern(v) => v + "-SNAPSHOT" - case Pattern(v) => v - case _ => "" - } - } - - def toolboxClasspath = { - val f = new java.io.File(s"target/scala-${scalaBinaryVersion}/classes") - if (!f.exists) sys.error(s"output directory ${f.getAbsolutePath} does not exist.") - f.getAbsolutePath - } + // returns e.g. target/scala-2.12/classes + // implementation is kludgy, but it's just test code. Scala version number formats and their + // relation to Scala binary versions are too diverse to attempt to do that mapping ourselves here, + // as we learned from experience. and we could use sbt-buildinfo to have sbt tell us, but that + // complicates the build since it does source generation (which may e.g. confuse IntelliJ). + // so this is, uh, fine? (crosses fingers) + def toolboxClasspath = + new java.io.File(this.getClass.getProtectionDomain.getCodeSource.getLocation.toURI) + .getParentFile.getParentFile def expectError(errorSnippet: String, compileOptions: String = "", baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String) { -- cgit v1.2.3