Add scala version so as to be able to find output directory when running tests.
This commit is contained in:
parent
8a83f70fc7
commit
ef70554b16
3 changed files with 13 additions and 5 deletions
|
@ -165,7 +165,8 @@ lazy val test = project
|
||||||
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit,"-a", "-q", "-v")),
|
Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit,"-a", "-q", "-v")),
|
||||||
Test / javacOptions := Seq(
|
Test / javacOptions := Seq(
|
||||||
"-Xlint:deprecation",
|
"-Xlint:deprecation",
|
||||||
"-Xlint:unchecked"
|
"-Xlint:unchecked",
|
||||||
|
s"-Dscala.version=${scalaVersion}"
|
||||||
),
|
),
|
||||||
Test / javaOptions := {
|
Test / javaOptions := {
|
||||||
val basedir = (baseDirectory in ThisBuild).value.getCanonicalFile
|
val basedir = (baseDirectory in ThisBuild).value.getCanonicalFile
|
||||||
|
|
|
@ -71,7 +71,8 @@ public class ClassLoaderTest extends DualTestCase {
|
||||||
String classLoaderPath = System.getProperty("testclassloader");
|
String classLoaderPath = System.getProperty("testclassloader");
|
||||||
if (classLoaderPath == null) {
|
if (classLoaderPath == null) {
|
||||||
String cwd = new java.io.File( "." ).getCanonicalFile().getParent();
|
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);
|
File classLoaderFile = new File(classLoaderPath);
|
||||||
if (!(classLoaderFile.exists() && classLoaderFile.isDirectory())) {
|
if (!(classLoaderFile.exists() && classLoaderFile.isDirectory())) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ public class SharedTestUtils {
|
||||||
public static String DEST_DIR = "testdestdir";
|
public static String DEST_DIR = "testdestdir";
|
||||||
public static String TEST_ENV_DIR = "testenvdirroot";
|
public static String TEST_ENV_DIR = "testenvdirroot";
|
||||||
public static String FAILURE_DIR = "failurecopydir";
|
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_TEST_DIR_ROOT = "target/envdata";
|
||||||
public static String DEFAULT_FAIL_DIR = "target/failures";
|
public static String DEFAULT_FAIL_DIR = "target/failures";
|
||||||
public static String NO_SYNC = "txnnosync";
|
public static String NO_SYNC = "txnnosync";
|
||||||
|
@ -48,13 +49,18 @@ public class SharedTestUtils {
|
||||||
static {
|
static {
|
||||||
DBCONFIG_CREATE.setAllowCreate(true);
|
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
|
* The environment store compiled class files and generated environment by
|
||||||
* test that is distinctive with test environment.
|
* test that is distinctive with test environment.
|
||||||
*/
|
*/
|
||||||
public static File getDestDir() {
|
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);
|
File file = new File(dir);
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
|
@ -67,7 +73,7 @@ public class SharedTestUtils {
|
||||||
* test that is distinctive with test environment.
|
* test that is distinctive with test environment.
|
||||||
*/
|
*/
|
||||||
public static File getDestDirChlid(String child) {
|
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);
|
File file = new File(dir, child);
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
|
Loading…
Reference in a new issue