Permalink
Browse files

properly wrap unknown test data structures in serializable ones

  • Loading branch information...
1 parent 3e74b92 commit a1a00526ff317b0247e3921a9beead59685fa75c @harrah harrah committed Jun 28, 2013
@@ -11,7 +11,7 @@ import Tests.{Output => TestOutput, _}
import ForkMain._
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 listeners = opts flatMap {
case Listeners(ls) => ls
@@ -46,7 +46,7 @@ private[sbt] object ForkTests {
os.writeBoolean(log.ansiCodesSupported)
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
os.writeObject(testsFiltered)
@@ -92,6 +92,12 @@ private[sbt] object ForkTests {
TestOutput(TestResult.Passed, Map.empty[String, SuiteResult], Iterable.empty)
} 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])
{
@@ -484,7 +484,7 @@ object Defaults extends BuildCommon
case Tests.Group(name, tests, runPolicy) =>
runPolicy match {
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 =>
Tests(frameworks, loader, runners, tests, config, s.log)
}
@@ -147,7 +147,7 @@ void runTests(ObjectInputStream is, final ObjectOutputStream os) throws Exceptio
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 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 @@ void run(ObjectInputStream is, ObjectOutputStream os) throws Exception {
} catch (Throwable t) {
try {
logError(os, "Uncaught exception when running tests: " + t.toString());
- write(os, t);
+ write(os, new ForkError(t));
} catch (Throwable t2) {
internalError(t2);
}
@@ -263,7 +263,7 @@ void run(ObjectInputStream is, ObjectOutputStream os) throws Exception {
void internalError(Throwable t) {
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;
if (err == null)
throwable = new OptionalThrowable();
@@ -288,8 +288,9 @@ ForkEvent testError(ObjectOutputStream os, TaskDef taskDef, String message) {
}
ForkEvent testError(ObjectOutputStream os, TaskDef taskDef, String message, Throwable t) {
logError(os, message);
- write(os, t);
- return testEvent(taskDef.fullyQualifiedName(), taskDef.fingerprint(), new SuiteSelector(), Status.Error, t, 0);
+ ForkError fe = new ForkError(t);
+ write(os, fe);
+ return testEvent(taskDef.fullyQualifiedName(), taskDef.fingerprint(), new SuiteSelector(), Status.Error, fe, 0);
}
}
}
@@ -1,6 +1,7 @@
package sbt;
import sbt.testing.*;
+import java.io.Serializable;
final class FrameworkWrapper implements Framework {

0 comments on commit a1a0052

Please sign in to comment.