mirror of https://github.com/sbt/sbt.git
properly wrap unknown test data structures in serializable ones
This commit is contained in:
parent
3e74b92bf8
commit
a1a00526ff
|
|
@ -11,7 +11,7 @@ import Tests.{Output => TestOutput, _}
|
||||||
import ForkMain._
|
import ForkMain._
|
||||||
|
|
||||||
private[sbt] object ForkTests {
|
private[sbt] object ForkTests {
|
||||||
def apply(runners: Map[TestFramework, Runner], tests: List[TestDefinition], config: Execution, loader: ClassLoader, classpath: Seq[File], fork: ForkOptions, log: Logger): Task[TestOutput] = {
|
def apply(runners: Map[TestFramework, Runner], tests: List[TestDefinition], config: Execution, classpath: Seq[File], fork: ForkOptions, log: Logger): Task[TestOutput] = {
|
||||||
val opts = config.options.toList
|
val opts = config.options.toList
|
||||||
val listeners = opts flatMap {
|
val listeners = opts flatMap {
|
||||||
case Listeners(ls) => ls
|
case Listeners(ls) => ls
|
||||||
|
|
@ -46,7 +46,7 @@ private[sbt] object ForkTests {
|
||||||
os.writeBoolean(log.ansiCodesSupported)
|
os.writeBoolean(log.ansiCodesSupported)
|
||||||
|
|
||||||
val testsFiltered = tests.filter(test => filters.forall(_(test.name))).map{
|
val testsFiltered = tests.filter(test => filters.forall(_(test.name))).map{
|
||||||
t => new TaskDef(t.name, t.fingerprint, t.explicitlySpecified, t.selectors)
|
t => new TaskDef(t.name, forkFingerprint(t.fingerprint), t.explicitlySpecified, t.selectors)
|
||||||
}.toArray
|
}.toArray
|
||||||
os.writeObject(testsFiltered)
|
os.writeObject(testsFiltered)
|
||||||
|
|
||||||
|
|
@ -92,6 +92,12 @@ private[sbt] object ForkTests {
|
||||||
TestOutput(TestResult.Passed, Map.empty[String, SuiteResult], Iterable.empty)
|
TestOutput(TestResult.Passed, Map.empty[String, SuiteResult], Iterable.empty)
|
||||||
} tagw (config.tags: _*)
|
} tagw (config.tags: _*)
|
||||||
}
|
}
|
||||||
|
private[this] def forkFingerprint(f: Fingerprint): Fingerprint with Serializable =
|
||||||
|
f match {
|
||||||
|
case s: SubclassFingerprint => new ForkMain.SubclassFingerscan(s)
|
||||||
|
case a: AnnotatedFingerprint => new ForkMain.AnnotatedFingerscan(a)
|
||||||
|
case _ => error("Unknown fingerprint type: " + f.getClass)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private final class React(is: ObjectInputStream, os: ObjectOutputStream, log: Logger, listeners: Seq[TestReportListener], results: mutable.Map[String, SuiteResult])
|
private final class React(is: ObjectInputStream, os: ObjectOutputStream, log: Logger, listeners: Seq[TestReportListener], results: mutable.Map[String, SuiteResult])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ object Defaults extends BuildCommon
|
||||||
case Tests.Group(name, tests, runPolicy) =>
|
case Tests.Group(name, tests, runPolicy) =>
|
||||||
runPolicy match {
|
runPolicy match {
|
||||||
case Tests.SubProcess(opts) =>
|
case Tests.SubProcess(opts) =>
|
||||||
ForkTests(runners, tests.toList, config, loader, cp.files, opts, s.log) tag Tags.ForkedTestGroup
|
ForkTests(runners, tests.toList, config, cp.files, opts, s.log) tag Tags.ForkedTestGroup
|
||||||
case Tests.InProcess =>
|
case Tests.InProcess =>
|
||||||
Tests(frameworks, loader, runners, tests, config, s.log)
|
Tests(frameworks, loader, runners, tests, config, s.log)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ public class ForkMain {
|
||||||
public void warn(String s) { write(os, new Object[]{ForkTags.Warn, s}); }
|
public void warn(String s) { write(os, new Object[]{ForkTags.Warn, s}); }
|
||||||
public void info(String s) { write(os, new Object[]{ForkTags.Info, s}); }
|
public void info(String s) { write(os, new Object[]{ForkTags.Info, s}); }
|
||||||
public void debug(String s) { write(os, new Object[]{ForkTags.Debug, s}); }
|
public void debug(String s) { write(os, new Object[]{ForkTags.Debug, s}); }
|
||||||
public void trace(Throwable t) { write(os, t); }
|
public void trace(Throwable t) { write(os, new ForkError(t)); }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ public class ForkMain {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
try {
|
try {
|
||||||
logError(os, "Uncaught exception when running tests: " + t.toString());
|
logError(os, "Uncaught exception when running tests: " + t.toString());
|
||||||
write(os, t);
|
write(os, new ForkError(t));
|
||||||
} catch (Throwable t2) {
|
} catch (Throwable t2) {
|
||||||
internalError(t2);
|
internalError(t2);
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +263,7 @@ public class ForkMain {
|
||||||
void internalError(Throwable t) {
|
void internalError(Throwable t) {
|
||||||
System.err.println("Internal error when running tests: " + t.toString());
|
System.err.println("Internal error when running tests: " + t.toString());
|
||||||
}
|
}
|
||||||
ForkEvent testEvent(final String fullyQualifiedName, final Fingerprint fingerprint, final Selector selector, final Status r, final Throwable err, final long duration) {
|
ForkEvent testEvent(final String fullyQualifiedName, final Fingerprint fingerprint, final Selector selector, final Status r, final ForkError err, final long duration) {
|
||||||
final OptionalThrowable throwable;
|
final OptionalThrowable throwable;
|
||||||
if (err == null)
|
if (err == null)
|
||||||
throwable = new OptionalThrowable();
|
throwable = new OptionalThrowable();
|
||||||
|
|
@ -288,8 +288,9 @@ public class ForkMain {
|
||||||
}
|
}
|
||||||
ForkEvent testError(ObjectOutputStream os, TaskDef taskDef, String message, Throwable t) {
|
ForkEvent testError(ObjectOutputStream os, TaskDef taskDef, String message, Throwable t) {
|
||||||
logError(os, message);
|
logError(os, message);
|
||||||
write(os, t);
|
ForkError fe = new ForkError(t);
|
||||||
return testEvent(taskDef.fullyQualifiedName(), taskDef.fingerprint(), new SuiteSelector(), Status.Error, t, 0);
|
write(os, fe);
|
||||||
|
return testEvent(taskDef.fullyQualifiedName(), taskDef.fingerprint(), new SuiteSelector(), Status.Error, fe, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package sbt;
|
package sbt;
|
||||||
|
|
||||||
import sbt.testing.*;
|
import sbt.testing.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
final class FrameworkWrapper implements Framework {
|
final class FrameworkWrapper implements Framework {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue