From ef70554b161007640b5faa16671814a0b0f34f89 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Thu, 21 Nov 2019 21:23:22 -0500 Subject: [PATCH] Add scala version so as to be able to find output directory when running tests. --- build.sbt | 3 ++- .../test/java/com/sleepycat/je/ClassLoaderTest.java | 3 ++- .../com/sleepycat/util/test/SharedTestUtils.java | 12 +++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index c8bed50..15266ee 100644 --- a/build.sbt +++ b/build.sbt @@ -165,7 +165,8 @@ lazy val test = project Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit,"-a", "-q", "-v")), Test / javacOptions := Seq( "-Xlint:deprecation", - "-Xlint:unchecked" + "-Xlint:unchecked", + s"-Dscala.version=${scalaVersion}" ), Test / javaOptions := { val basedir = (baseDirectory in ThisBuild).value.getCanonicalFile diff --git a/stasis-test/src/test/java/com/sleepycat/je/ClassLoaderTest.java b/stasis-test/src/test/java/com/sleepycat/je/ClassLoaderTest.java index 1f3660c..bfd7b30 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/ClassLoaderTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/ClassLoaderTest.java @@ -71,7 +71,8 @@ public class ClassLoaderTest extends DualTestCase { String classLoaderPath = System.getProperty("testclassloader"); if (classLoaderPath == null) { String cwd = new java.io.File( "." ).getCanonicalFile().getParent(); - classLoaderPath = cwd + "/stasis-test-examples/target/scala-2.12/test-classes"; + String testdir = SharedTestUtils.defaultDestDir(); + classLoaderPath = cwd + "/stasis-test-examples/" + testdir; } File classLoaderFile = new File(classLoaderPath); if (!(classLoaderFile.exists() && classLoaderFile.isDirectory())) { diff --git a/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java b/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java index 908b987..dd405c4 100644 --- a/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java +++ b/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.channels.FileChannel; +import java.util.Properties; import junit.framework.TestCase; @@ -37,7 +38,7 @@ public class SharedTestUtils { public static String DEST_DIR = "testdestdir"; public static String TEST_ENV_DIR = "testenvdirroot"; public static String FAILURE_DIR = "failurecopydir"; - public static String DEFAULT_DEST_DIR = "target/scala-2.12/test-classes"; // util.Properties.versionNumberString + public static String DEFAULT_DEST_DIR = "target/scala-%s/test-classes"; // util.Properties.versionNumberString public static String DEFAULT_TEST_DIR_ROOT = "target/envdata"; public static String DEFAULT_FAIL_DIR = "target/failures"; public static String NO_SYNC = "txnnosync"; @@ -48,13 +49,18 @@ public class SharedTestUtils { static { DBCONFIG_CREATE.setAllowCreate(true); } + + public static String defaultDestDir() { + String version = System.getProperty("scala.version"); + return String.format(DEFAULT_DEST_DIR, version == null ? "2.13" : version); + } /** * The environment store compiled class files and generated environment by * test that is distinctive with test environment. */ public static File getDestDir() { - String dir = System.getProperty(DEST_DIR, DEFAULT_DEST_DIR); + String dir = System.getProperty(DEST_DIR, defaultDestDir()); File file = new File(dir); if (!file.isDirectory()) file.mkdir(); @@ -67,7 +73,7 @@ public class SharedTestUtils { * test that is distinctive with test environment. */ public static File getDestDirChlid(String child) { - String dir = System.getProperty(DEST_DIR, DEFAULT_DEST_DIR); + String dir = System.getProperty(DEST_DIR, defaultDestDir()); File file = new File(dir, child); return file;