diff options
author | Seth Tisue <seth@tisue.net> | 2018-03-05 19:47:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 19:47:07 -0800 |
commit | 7d5ebe62336ab99a5988d4ef472fd486ec6cbe49 (patch) | |
tree | 7ada5edf8b0b192018f3ce9f7d62d1178257f088 | |
parent | d4a72ac1fadad67df8ad15b3763212e129e36db6 (diff) | |
download | scala-async-7d5ebe62336ab99a5988d4ef472fd486ec6cbe49.tar.gz scala-async-7d5ebe62336ab99a5988d4ef472fd486ec6cbe49.tar.bz2 scala-async-7d5ebe62336ab99a5988d4ef472fd486ec6cbe49.zip |
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
-rw-r--r-- | src/test/scala/scala/async/package.scala | 26 |
1 files 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) { |