mirror of https://github.com/sbt/sbt.git
Cleanup testAgentProj
This commit is contained in:
parent
222a970080
commit
d77e769635
|
|
@ -3,10 +3,10 @@ package sbt;
|
|||
import java.io.Serializable;
|
||||
|
||||
public final class ForkConfiguration implements Serializable {
|
||||
private boolean ansiCodesSupported;
|
||||
private boolean parallel;
|
||||
private final boolean ansiCodesSupported;
|
||||
private final boolean parallel;
|
||||
|
||||
public ForkConfiguration(boolean ansiCodesSupported, boolean parallel) {
|
||||
public ForkConfiguration(final boolean ansiCodesSupported, final boolean parallel) {
|
||||
this.ansiCodesSupported = ansiCodesSupported;
|
||||
this.parallel = parallel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class ForkMain {
|
||||
final public class ForkMain {
|
||||
|
||||
// serializables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static class SubclassFingerscan implements SubclassFingerprint, Serializable {
|
||||
private boolean isModule;
|
||||
private String superclassName;
|
||||
private boolean requireNoArgConstructor;
|
||||
SubclassFingerscan(SubclassFingerprint print) {
|
||||
final static class SubclassFingerscan implements SubclassFingerprint, Serializable {
|
||||
private final boolean isModule;
|
||||
private final String superclassName;
|
||||
private final boolean requireNoArgConstructor;
|
||||
SubclassFingerscan(final SubclassFingerprint print) {
|
||||
isModule = print.isModule();
|
||||
superclassName = print.superclassName();
|
||||
requireNoArgConstructor = print.requireNoArgConstructor();
|
||||
|
|
@ -35,10 +35,10 @@ public class ForkMain {
|
|||
public boolean requireNoArgConstructor() { return requireNoArgConstructor; }
|
||||
}
|
||||
|
||||
static class AnnotatedFingerscan implements AnnotatedFingerprint, Serializable {
|
||||
private boolean isModule;
|
||||
private String annotationName;
|
||||
AnnotatedFingerscan(AnnotatedFingerprint print) {
|
||||
final static class AnnotatedFingerscan implements AnnotatedFingerprint, Serializable {
|
||||
private final boolean isModule;
|
||||
private final String annotationName;
|
||||
AnnotatedFingerscan(final AnnotatedFingerprint print) {
|
||||
isModule = print.isModule();
|
||||
annotationName = print.annotationName();
|
||||
}
|
||||
|
|
@ -46,34 +46,34 @@ public class ForkMain {
|
|||
public String annotationName() { return annotationName; }
|
||||
}
|
||||
|
||||
static class ForkEvent implements Event, Serializable {
|
||||
private String fullyQualifiedName;
|
||||
private Fingerprint fingerprint;
|
||||
private Selector selector;
|
||||
private Status status;
|
||||
private OptionalThrowable throwable;
|
||||
private long duration;
|
||||
final static class ForkEvent implements Event, Serializable {
|
||||
private final String fullyQualifiedName;
|
||||
private final Fingerprint fingerprint;
|
||||
private final Selector selector;
|
||||
private final Status status;
|
||||
private final OptionalThrowable throwable;
|
||||
private final long duration;
|
||||
|
||||
ForkEvent(Event e) {
|
||||
ForkEvent(final Event e) {
|
||||
fullyQualifiedName = e.fullyQualifiedName();
|
||||
Fingerprint rawFingerprint = e.fingerprint();
|
||||
final Fingerprint rawFingerprint = e.fingerprint();
|
||||
|
||||
if (rawFingerprint instanceof SubclassFingerprint)
|
||||
this.fingerprint = new SubclassFingerscan((SubclassFingerprint) rawFingerprint);
|
||||
fingerprint = new SubclassFingerscan((SubclassFingerprint) rawFingerprint);
|
||||
else
|
||||
this.fingerprint = new AnnotatedFingerscan((AnnotatedFingerprint) rawFingerprint);
|
||||
fingerprint = new AnnotatedFingerscan((AnnotatedFingerprint) rawFingerprint);
|
||||
|
||||
selector = e.selector();
|
||||
checkSerializableSelector(selector);
|
||||
status = e.status();
|
||||
OptionalThrowable originalThrowable = e.throwable();
|
||||
final OptionalThrowable originalThrowable = e.throwable();
|
||||
|
||||
if (originalThrowable.isDefined())
|
||||
this.throwable = new OptionalThrowable(new ForkError(originalThrowable.get()));
|
||||
throwable = new OptionalThrowable(new ForkError(originalThrowable.get()));
|
||||
else
|
||||
this.throwable = originalThrowable;
|
||||
throwable = originalThrowable;
|
||||
|
||||
this.duration = e.duration();
|
||||
duration = e.duration();
|
||||
}
|
||||
|
||||
public String fullyQualifiedName() { return fullyQualifiedName; }
|
||||
|
|
@ -83,7 +83,7 @@ public class ForkMain {
|
|||
public OptionalThrowable throwable() { return throwable; }
|
||||
public long duration() { return duration; }
|
||||
|
||||
static void checkSerializableSelector(Selector selector) {
|
||||
private static void checkSerializableSelector(final Selector selector) {
|
||||
if (! (selector instanceof Serializable)) {
|
||||
throw new UnsupportedOperationException("Selector implementation must be Serializable, but " + selector.getClass().getName() + " is not.");
|
||||
}
|
||||
|
|
@ -93,11 +93,11 @@ public class ForkMain {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static class ForkError extends Exception {
|
||||
private String originalMessage;
|
||||
private String originalName;
|
||||
final static class ForkError extends Exception {
|
||||
private final String originalMessage;
|
||||
private final String originalName;
|
||||
private ForkError cause;
|
||||
ForkError(Throwable t) {
|
||||
ForkError(final Throwable t) {
|
||||
originalMessage = t.getMessage();
|
||||
originalName = t.getClass().getName();
|
||||
setStackTrace(t.getStackTrace());
|
||||
|
|
@ -111,8 +111,8 @@ public class ForkMain {
|
|||
// main
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Socket socket = new Socket(InetAddress.getByName(null), Integer.valueOf(args[0]));
|
||||
public static void main(final String[] args) throws Exception {
|
||||
final Socket socket = new Socket(InetAddress.getByName(null), Integer.valueOf(args[0]));
|
||||
final ObjectInputStream is = new ObjectInputStream(socket.getInputStream());
|
||||
final ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream());
|
||||
// Must flush the header that the constructor writes, otherwise the ObjectInputStream on the other end may block indefinitely
|
||||
|
|
@ -132,76 +132,76 @@ public class ForkMain {
|
|||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
private static class Run {
|
||||
final private static class Run {
|
||||
|
||||
void run(ObjectInputStream is, ObjectOutputStream os) {
|
||||
private void run(final ObjectInputStream is, final ObjectOutputStream os) {
|
||||
try {
|
||||
runTests(is, os);
|
||||
} catch (RunAborted e) {
|
||||
} catch (final RunAborted e) {
|
||||
internalError(e);
|
||||
} catch (Throwable t) {
|
||||
} catch (final Throwable t) {
|
||||
try {
|
||||
logError(os, "Uncaught exception when running tests: " + t.toString());
|
||||
write(os, new ForkError(t));
|
||||
} catch (Throwable t2) {
|
||||
} catch (final Throwable t2) {
|
||||
internalError(t2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean matches(Fingerprint f1, Fingerprint f2) {
|
||||
private boolean matches(final Fingerprint f1, final Fingerprint f2) {
|
||||
if (f1 instanceof SubclassFingerprint && f2 instanceof SubclassFingerprint) {
|
||||
final SubclassFingerprint sf1 = (SubclassFingerprint) f1;
|
||||
final SubclassFingerprint sf2 = (SubclassFingerprint) f2;
|
||||
return sf1.isModule() == sf2.isModule() && sf1.superclassName().equals(sf2.superclassName());
|
||||
} else if (f1 instanceof AnnotatedFingerprint && f2 instanceof AnnotatedFingerprint) {
|
||||
AnnotatedFingerprint af1 = (AnnotatedFingerprint) f1;
|
||||
AnnotatedFingerprint af2 = (AnnotatedFingerprint) f2;
|
||||
final AnnotatedFingerprint af1 = (AnnotatedFingerprint) f1;
|
||||
final AnnotatedFingerprint af2 = (AnnotatedFingerprint) f2;
|
||||
return af1.isModule() == af2.isModule() && af1.annotationName().equals(af2.annotationName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class RunAborted extends RuntimeException {
|
||||
RunAborted(Exception e) { super(e); }
|
||||
RunAborted(final Exception e) { super(e); }
|
||||
}
|
||||
|
||||
synchronized void write(ObjectOutputStream os, Object obj) {
|
||||
private synchronized void write(final ObjectOutputStream os, final Object obj) {
|
||||
try {
|
||||
os.writeObject(obj);
|
||||
os.flush();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RunAborted(e);
|
||||
}
|
||||
}
|
||||
|
||||
void log(ObjectOutputStream os, String message, ForkTags level) {
|
||||
private void log(final ObjectOutputStream os, final String message, final ForkTags level) {
|
||||
write(os, new Object[]{level, message});
|
||||
}
|
||||
|
||||
void logDebug(ObjectOutputStream os, String message) { log(os, message, ForkTags.Debug); }
|
||||
void logInfo(ObjectOutputStream os, String message) { log(os, message, ForkTags.Info); }
|
||||
void logWarn(ObjectOutputStream os, String message) { log(os, message, ForkTags.Warn); }
|
||||
void logError(ObjectOutputStream os, String message) { log(os, message, ForkTags.Error); }
|
||||
private void logDebug(final ObjectOutputStream os, final String message) { log(os, message, ForkTags.Debug); }
|
||||
private void logInfo(final ObjectOutputStream os, final String message) { log(os, message, ForkTags.Info); }
|
||||
private void logWarn(final ObjectOutputStream os, final String message) { log(os, message, ForkTags.Warn); }
|
||||
private void logError(final ObjectOutputStream os, final String message) { log(os, message, ForkTags.Error); }
|
||||
|
||||
Logger remoteLogger(final boolean ansiCodesSupported, final ObjectOutputStream os) {
|
||||
private Logger remoteLogger(final boolean ansiCodesSupported, final ObjectOutputStream os) {
|
||||
return new Logger() {
|
||||
public boolean ansiCodesSupported() { return ansiCodesSupported; }
|
||||
public void error(String s) { logError(os, s); }
|
||||
public void warn(String s) { logWarn(os, s); }
|
||||
public void info(String s) { logInfo(os, s); }
|
||||
public void debug(String s) { logDebug(os, s); }
|
||||
public void trace(Throwable t) { write(os, new ForkError(t)); }
|
||||
public void error(final String s) { logError(os, s); }
|
||||
public void warn(final String s) { logWarn(os, s); }
|
||||
public void info(final String s) { logInfo(os, s); }
|
||||
public void debug(final String s) { logDebug(os, s); }
|
||||
public void trace(final Throwable t) { write(os, new ForkError(t)); }
|
||||
};
|
||||
}
|
||||
|
||||
void writeEvents(ObjectOutputStream os, TaskDef taskDef, ForkEvent[] events) {
|
||||
private void writeEvents(final ObjectOutputStream os, final TaskDef taskDef, final ForkEvent[] events) {
|
||||
write(os, new Object[]{taskDef.fullyQualifiedName(), events});
|
||||
}
|
||||
|
||||
ExecutorService executorService(ForkConfiguration config, ObjectOutputStream os) {
|
||||
private ExecutorService executorService(final ForkConfiguration config, final ObjectOutputStream os) {
|
||||
if(config.isParallel()) {
|
||||
int nbThreads = Runtime.getRuntime().availableProcessors();
|
||||
final int nbThreads = Runtime.getRuntime().availableProcessors();
|
||||
logDebug(os, "Create a test executor with a thread pool of " + nbThreads + " threads.");
|
||||
// more options later...
|
||||
// TODO we might want to configure the blocking queue with size #proc
|
||||
|
|
@ -212,12 +212,12 @@ public class ForkMain {
|
|||
}
|
||||
}
|
||||
|
||||
void runTests(ObjectInputStream is, final ObjectOutputStream os) throws Exception {
|
||||
private void runTests(final ObjectInputStream is, final ObjectOutputStream os) throws Exception {
|
||||
final ForkConfiguration config = (ForkConfiguration) is.readObject();
|
||||
ExecutorService executor = executorService(config, os);
|
||||
final ExecutorService executor = executorService(config, os);
|
||||
final TaskDef[] tests = (TaskDef[]) is.readObject();
|
||||
int nFrameworks = is.readInt();
|
||||
Logger[] loggers = { remoteLogger(config.isAnsiCodesSupported(), os) };
|
||||
final int nFrameworks = is.readInt();
|
||||
final Logger[] loggers = { remoteLogger(config.isAnsiCodesSupported(), os) };
|
||||
|
||||
for (int i = 0; i < nFrameworks; i++) {
|
||||
final String[] implClassNames = (String[]) is.readObject();
|
||||
|
|
@ -225,15 +225,15 @@ public class ForkMain {
|
|||
final String[] remoteFrameworkArgs = (String[]) is.readObject();
|
||||
|
||||
Framework framework = null;
|
||||
for (String implClassName : implClassNames) {
|
||||
for (final String implClassName : implClassNames) {
|
||||
try {
|
||||
Object rawFramework = Class.forName(implClassName).newInstance();
|
||||
final Object rawFramework = Class.forName(implClassName).newInstance();
|
||||
if (rawFramework instanceof Framework)
|
||||
framework = (Framework) rawFramework;
|
||||
else
|
||||
framework = new FrameworkWrapper((org.scalatools.testing.Framework) rawFramework);
|
||||
break;
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (final ClassNotFoundException e) {
|
||||
logDebug(os, "Framework implementation '" + implClassName + "' not present.");
|
||||
}
|
||||
}
|
||||
|
|
@ -241,16 +241,16 @@ public class ForkMain {
|
|||
if (framework == null)
|
||||
continue;
|
||||
|
||||
ArrayList<TaskDef> filteredTests = new ArrayList<TaskDef>();
|
||||
for (Fingerprint testFingerprint : framework.fingerprints()) {
|
||||
for (TaskDef test : tests) {
|
||||
final ArrayList<TaskDef> filteredTests = new ArrayList<TaskDef>();
|
||||
for (final Fingerprint testFingerprint : framework.fingerprints()) {
|
||||
for (final TaskDef test : tests) {
|
||||
// TODO: To pass in correct explicitlySpecified and selectors
|
||||
if (matches(testFingerprint, test.fingerprint()))
|
||||
filteredTests.add(new TaskDef(test.fullyQualifiedName(), test.fingerprint(), test.explicitlySpecified(), test.selectors()));
|
||||
}
|
||||
}
|
||||
final Runner runner = framework.runner(frameworkArgs, remoteFrameworkArgs, getClass().getClassLoader());
|
||||
Task[] tasks = runner.tasks(filteredTests.toArray(new TaskDef[filteredTests.size()]));
|
||||
final Task[] tasks = runner.tasks(filteredTests.toArray(new TaskDef[filteredTests.size()]));
|
||||
logDebug(os, "Runner for " + framework.getClass().getName() + " produced " + tasks.length + " initial tasks for " + filteredTests.size() + " tests.");
|
||||
|
||||
runTestTasks(executor, tasks, loggers, os);
|
||||
|
|
@ -261,20 +261,20 @@ public class ForkMain {
|
|||
is.readObject();
|
||||
}
|
||||
|
||||
void runTestTasks(ExecutorService executor, Task[] tasks, Logger[] loggers, ObjectOutputStream os) {
|
||||
private void runTestTasks(final ExecutorService executor, final Task[] tasks, final Logger[] loggers, final ObjectOutputStream os) {
|
||||
if( tasks.length > 0 ) {
|
||||
List<Future<Task[]>> futureNestedTasks = new ArrayList<Future<Task[]>>();
|
||||
for( Task task : tasks ) {
|
||||
final List<Future<Task[]>> futureNestedTasks = new ArrayList<Future<Task[]>>();
|
||||
for( final Task task : tasks ) {
|
||||
futureNestedTasks.add(runTest(executor, task, loggers, os));
|
||||
}
|
||||
|
||||
// Note: this could be optimized further, we could have a callback once a test finishes that executes immediately the nested tasks
|
||||
// At the moment, I'm especially interested in JUnit, which doesn't have nested tasks.
|
||||
List<Task> nestedTasks = new ArrayList<Task>();
|
||||
for( Future<Task[]> futureNestedTask : futureNestedTasks ) {
|
||||
final List<Task> nestedTasks = new ArrayList<Task>();
|
||||
for( final Future<Task[]> futureNestedTask : futureNestedTasks ) {
|
||||
try {
|
||||
nestedTasks.addAll( Arrays.asList(futureNestedTask.get()));
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logError(os, "Failed to execute task " + futureNestedTask);
|
||||
}
|
||||
}
|
||||
|
|
@ -282,23 +282,23 @@ public class ForkMain {
|
|||
}
|
||||
}
|
||||
|
||||
Future<Task[]> runTest(ExecutorService executor, final Task task, final Logger[] loggers, final ObjectOutputStream os) {
|
||||
private Future<Task[]> runTest(final ExecutorService executor, final Task task, final Logger[] loggers, final ObjectOutputStream os) {
|
||||
return executor.submit(new Callable<Task[]>() {
|
||||
@Override
|
||||
public Task[] call() {
|
||||
ForkEvent[] events;
|
||||
Task[] nestedTasks;
|
||||
TaskDef taskDef = task.taskDef();
|
||||
final TaskDef taskDef = task.taskDef();
|
||||
try {
|
||||
final List<ForkEvent> eventList = new ArrayList<ForkEvent>();
|
||||
EventHandler handler = new EventHandler() { public void handle(Event e){ eventList.add(new ForkEvent(e)); } };
|
||||
final EventHandler handler = new EventHandler() { public void handle(final Event e){ eventList.add(new ForkEvent(e)); } };
|
||||
logDebug(os, " Running " + taskDef);
|
||||
nestedTasks = task.execute(handler, loggers);
|
||||
if(nestedTasks.length > 0 || eventList.size() > 0)
|
||||
logDebug(os, " Produced " + nestedTasks.length + " nested tasks and " + eventList.size() + " events.");
|
||||
events = eventList.toArray(new ForkEvent[eventList.size()]);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
catch (final Throwable t) {
|
||||
nestedTasks = new Task[0];
|
||||
events = new ForkEvent[] { testError(os, taskDef, "Uncaught exception when running " + taskDef.fullyQualifiedName() + ": " + t.toString(), t) };
|
||||
}
|
||||
|
|
@ -308,11 +308,11 @@ public class ForkMain {
|
|||
});
|
||||
}
|
||||
|
||||
void internalError(Throwable t) {
|
||||
private void internalError(final 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 ForkError err, final long duration) {
|
||||
private 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();
|
||||
|
|
@ -332,9 +332,9 @@ public class ForkMain {
|
|||
});
|
||||
}
|
||||
|
||||
ForkEvent testError(ObjectOutputStream os, TaskDef taskDef, String message, Throwable t) {
|
||||
private ForkEvent testError(final ObjectOutputStream os, final TaskDef taskDef, final String message, final Throwable t) {
|
||||
logError(os, message);
|
||||
ForkError fe = new ForkError(t);
|
||||
final ForkError fe = new ForkError(t);
|
||||
write(os, fe);
|
||||
return testEvent(taskDef.fullyQualifiedName(), taskDef.fingerprint(), new SuiteSelector(), Status.Error, fe, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,3 @@ package sbt;
|
|||
public enum ForkTags {
|
||||
Error, Warn, Info, Debug, Done
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import sbt.testing.*;
|
|||
*/
|
||||
final class FrameworkWrapper implements Framework {
|
||||
|
||||
private org.scalatools.testing.Framework oldFramework;
|
||||
private final org.scalatools.testing.Framework oldFramework;
|
||||
|
||||
public FrameworkWrapper(org.scalatools.testing.Framework oldFramework) {
|
||||
FrameworkWrapper(final org.scalatools.testing.Framework oldFramework) {
|
||||
this.oldFramework = oldFramework;
|
||||
}
|
||||
|
||||
|
|
@ -19,11 +19,11 @@ final class FrameworkWrapper implements Framework {
|
|||
}
|
||||
|
||||
public Fingerprint[] fingerprints() {
|
||||
org.scalatools.testing.Fingerprint[] oldFingerprints = oldFramework.tests();
|
||||
int length = oldFingerprints.length;
|
||||
Fingerprint[] fingerprints = new Fingerprint[length];
|
||||
final org.scalatools.testing.Fingerprint[] oldFingerprints = oldFramework.tests();
|
||||
final int length = oldFingerprints.length;
|
||||
final Fingerprint[] fingerprints = new Fingerprint[length];
|
||||
for (int i=0; i < length; i++) {
|
||||
org.scalatools.testing.Fingerprint oldFingerprint = oldFingerprints[i];
|
||||
final org.scalatools.testing.Fingerprint oldFingerprint = oldFingerprints[i];
|
||||
if (oldFingerprint instanceof org.scalatools.testing.TestFingerprint)
|
||||
fingerprints[i] = new SubclassFingerprintWrapper((org.scalatools.testing.TestFingerprint) oldFingerprint);
|
||||
else if (oldFingerprint instanceof org.scalatools.testing.SubclassFingerprint)
|
||||
|
|
@ -34,20 +34,20 @@ final class FrameworkWrapper implements Framework {
|
|||
return fingerprints;
|
||||
}
|
||||
|
||||
public Runner runner(String[] args, String[] remoteArgs, ClassLoader testClassLoader) {
|
||||
public Runner runner(final String[] args, final String[] remoteArgs, final ClassLoader testClassLoader) {
|
||||
return new RunnerWrapper(oldFramework, testClassLoader, args);
|
||||
}
|
||||
}
|
||||
|
||||
final class SubclassFingerprintWrapper implements SubclassFingerprint {
|
||||
private String superclassName;
|
||||
private boolean isModule;
|
||||
private boolean requireNoArgConstructor;
|
||||
private final String superclassName;
|
||||
private final boolean isModule;
|
||||
private final boolean requireNoArgConstructor;
|
||||
|
||||
public SubclassFingerprintWrapper(org.scalatools.testing.SubclassFingerprint oldFingerprint) {
|
||||
this.superclassName = oldFingerprint.superClassName();
|
||||
this.isModule = oldFingerprint.isModule();
|
||||
this.requireNoArgConstructor = false; // Old framework SubclassFingerprint does not require no arg constructor
|
||||
SubclassFingerprintWrapper(final org.scalatools.testing.SubclassFingerprint oldFingerprint) {
|
||||
superclassName = oldFingerprint.superClassName();
|
||||
isModule = oldFingerprint.isModule();
|
||||
requireNoArgConstructor = false; // Old framework SubclassFingerprint does not require no arg constructor
|
||||
}
|
||||
|
||||
public boolean isModule() {
|
||||
|
|
@ -57,19 +57,19 @@ final class SubclassFingerprintWrapper implements SubclassFingerprint {
|
|||
public String superclassName() {
|
||||
return superclassName;
|
||||
}
|
||||
|
||||
|
||||
public boolean requireNoArgConstructor() {
|
||||
return requireNoArgConstructor;
|
||||
}
|
||||
}
|
||||
|
||||
final class AnnotatedFingerprintWrapper implements AnnotatedFingerprint {
|
||||
private String annotationName;
|
||||
private boolean isModule;
|
||||
private final String annotationName;
|
||||
private final boolean isModule;
|
||||
|
||||
public AnnotatedFingerprintWrapper(org.scalatools.testing.AnnotatedFingerprint oldFingerprint) {
|
||||
this.annotationName = oldFingerprint.annotationName();
|
||||
this.isModule = oldFingerprint.isModule();
|
||||
AnnotatedFingerprintWrapper(final org.scalatools.testing.AnnotatedFingerprint oldFingerprint) {
|
||||
annotationName = oldFingerprint.annotationName();
|
||||
isModule = oldFingerprint.isModule();
|
||||
}
|
||||
|
||||
public boolean isModule() {
|
||||
|
|
@ -83,33 +83,33 @@ final class AnnotatedFingerprintWrapper implements AnnotatedFingerprint {
|
|||
|
||||
final class EventHandlerWrapper implements org.scalatools.testing.EventHandler {
|
||||
|
||||
private EventHandler newEventHandler;
|
||||
private String fullyQualifiedName;
|
||||
private Fingerprint fingerprint;
|
||||
private final EventHandler newEventHandler;
|
||||
private final String fullyQualifiedName;
|
||||
private final Fingerprint fingerprint;
|
||||
|
||||
public EventHandlerWrapper(EventHandler newEventHandler, String fullyQualifiedName, Fingerprint fingerprint) {
|
||||
EventHandlerWrapper(final EventHandler newEventHandler, final String fullyQualifiedName, final Fingerprint fingerprint) {
|
||||
this.newEventHandler = newEventHandler;
|
||||
this.fullyQualifiedName = fullyQualifiedName;
|
||||
this.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
public void handle(org.scalatools.testing.Event oldEvent) {
|
||||
public void handle(final org.scalatools.testing.Event oldEvent) {
|
||||
newEventHandler.handle(new EventWrapper(oldEvent, fullyQualifiedName, fingerprint));
|
||||
}
|
||||
}
|
||||
|
||||
final class EventWrapper implements Event {
|
||||
|
||||
private org.scalatools.testing.Event oldEvent;
|
||||
private String className;
|
||||
private Fingerprint fingerprint;
|
||||
private OptionalThrowable throwable;
|
||||
private final org.scalatools.testing.Event oldEvent;
|
||||
private final String className;
|
||||
private final Fingerprint fingerprint;
|
||||
private final OptionalThrowable throwable;
|
||||
|
||||
public EventWrapper(org.scalatools.testing.Event oldEvent, String className, Fingerprint fingerprint) {
|
||||
EventWrapper(final org.scalatools.testing.Event oldEvent, final String className, final Fingerprint fingerprint) {
|
||||
this.oldEvent = oldEvent;
|
||||
this.className = className;
|
||||
this.fingerprint = fingerprint;
|
||||
Throwable oldThrowable = oldEvent.error();
|
||||
final Throwable oldThrowable = oldEvent.error();
|
||||
if (oldThrowable == null)
|
||||
throwable = new OptionalThrowable();
|
||||
else
|
||||
|
|
@ -121,7 +121,7 @@ final class EventWrapper implements Event {
|
|||
}
|
||||
|
||||
public Fingerprint fingerprint() {
|
||||
return fingerprint;
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
public Selector selector() {
|
||||
|
|
@ -130,9 +130,9 @@ final class EventWrapper implements Event {
|
|||
|
||||
public Status status() {
|
||||
switch (oldEvent.result()) {
|
||||
case Success:
|
||||
case Success:
|
||||
return Status.Success;
|
||||
case Error:
|
||||
case Error:
|
||||
return Status.Error;
|
||||
case Failure:
|
||||
return Status.Failure;
|
||||
|
|
@ -154,47 +154,47 @@ final class EventWrapper implements Event {
|
|||
|
||||
final class RunnerWrapper implements Runner {
|
||||
|
||||
private org.scalatools.testing.Framework oldFramework;
|
||||
private ClassLoader testClassLoader;
|
||||
private String[] args;
|
||||
private final org.scalatools.testing.Framework oldFramework;
|
||||
private final ClassLoader testClassLoader;
|
||||
private final String[] args;
|
||||
|
||||
public RunnerWrapper(org.scalatools.testing.Framework oldFramework, ClassLoader testClassLoader, String[] args) {
|
||||
RunnerWrapper(final org.scalatools.testing.Framework oldFramework, final ClassLoader testClassLoader, final String[] args) {
|
||||
this.oldFramework = oldFramework;
|
||||
this.testClassLoader = testClassLoader;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public Task[] tasks(TaskDef[] taskDefs) {
|
||||
int length = taskDefs.length;
|
||||
Task[] tasks = new Task[length];
|
||||
|
||||
public Task[] tasks(final TaskDef[] taskDefs) {
|
||||
final int length = taskDefs.length;
|
||||
final Task[] tasks = new Task[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
TaskDef taskDef = taskDefs[i];
|
||||
final TaskDef taskDef = taskDefs[i];
|
||||
tasks[i] = createTask(taskDef);
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public Task createTask(final TaskDef taskDef) {
|
||||
private Task createTask(final TaskDef taskDef) {
|
||||
return new Task() {
|
||||
public String[] tags() {
|
||||
return new String[0]; // Old framework does not support tags
|
||||
}
|
||||
|
||||
|
||||
private org.scalatools.testing.Logger createOldLogger(final Logger logger) {
|
||||
return new org.scalatools.testing.Logger() {
|
||||
public boolean ansiCodesSupported() { return logger.ansiCodesSupported(); }
|
||||
public void error(String msg) { logger.error(msg); }
|
||||
public void warn(String msg) { logger.warn(msg); }
|
||||
public void info(String msg) { logger.info(msg); }
|
||||
public void debug(String msg) { logger.debug(msg); }
|
||||
public void trace(Throwable t) { logger.trace(t); }
|
||||
public boolean ansiCodesSupported() { return logger.ansiCodesSupported(); }
|
||||
public void error(final String msg) { logger.error(msg); }
|
||||
public void warn(final String msg) { logger.warn(msg); }
|
||||
public void info(final String msg) { logger.info(msg); }
|
||||
public void debug(final String msg) { logger.debug(msg); }
|
||||
public void trace(final Throwable t) { logger.trace(t); }
|
||||
};
|
||||
}
|
||||
|
||||
private void runRunner(org.scalatools.testing.Runner runner, Fingerprint fingerprint, EventHandler eventHandler) {
|
||||
|
||||
private void runRunner(final org.scalatools.testing.Runner runner, final Fingerprint fingerprint, final EventHandler eventHandler) {
|
||||
// Old runner only support subclass fingerprint.
|
||||
final SubclassFingerprint subclassFingerprint = (SubclassFingerprint) fingerprint;
|
||||
org.scalatools.testing.TestFingerprint oldFingerprint =
|
||||
final org.scalatools.testing.TestFingerprint oldFingerprint =
|
||||
new org.scalatools.testing.TestFingerprint() {
|
||||
public boolean isModule() { return subclassFingerprint.isModule(); }
|
||||
public String superClassName() { return subclassFingerprint.superclassName(); }
|
||||
|
|
@ -202,9 +202,9 @@ final class RunnerWrapper implements Runner {
|
|||
final String name = taskDef.fullyQualifiedName();
|
||||
runner.run(name, oldFingerprint, new EventHandlerWrapper(eventHandler, name, subclassFingerprint), args);
|
||||
}
|
||||
|
||||
private void runRunner2(org.scalatools.testing.Runner2 runner, Fingerprint fingerprint, EventHandler eventHandler) {
|
||||
org.scalatools.testing.Fingerprint oldFingerprint = null;
|
||||
|
||||
private void runRunner2(final org.scalatools.testing.Runner2 runner, final Fingerprint fingerprint, final EventHandler eventHandler) {
|
||||
final org.scalatools.testing.Fingerprint oldFingerprint;
|
||||
if (fingerprint instanceof SubclassFingerprint) {
|
||||
final SubclassFingerprint subclassFingerprint = (SubclassFingerprint) fingerprint;
|
||||
oldFingerprint = new org.scalatools.testing.SubclassFingerprint() {
|
||||
|
|
@ -222,10 +222,10 @@ final class RunnerWrapper implements Runner {
|
|||
final String name = taskDef.fullyQualifiedName();
|
||||
runner.run(name, oldFingerprint, new EventHandlerWrapper(eventHandler, name, fingerprint), args);
|
||||
}
|
||||
|
||||
public Task[] execute(EventHandler eventHandler, Logger[] loggers) {
|
||||
int length = loggers.length;
|
||||
org.scalatools.testing.Logger[] oldLoggers = new org.scalatools.testing.Logger[length];
|
||||
|
||||
public Task[] execute(final EventHandler eventHandler, final Logger[] loggers) {
|
||||
final int length = loggers.length;
|
||||
final org.scalatools.testing.Logger[] oldLoggers = new org.scalatools.testing.Logger[length];
|
||||
for (int i=0; i<length; i++) {
|
||||
oldLoggers[i] = createOldLogger(loggers[i]);
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ final class RunnerWrapper implements Runner {
|
|||
}
|
||||
return new Task[0];
|
||||
}
|
||||
|
||||
|
||||
public TaskDef taskDef() {
|
||||
return taskDef;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue