Added explicitlySpecified and selectors field to ForkTestDefinition, and change ForkMain to use explicitlySpecified and selectors value sent from ForkTests.

This commit is contained in:
cheeseng 2013-06-27 18:11:47 +08:00
parent 0c66d1a5d3
commit 86f47bd67d
2 changed files with 17 additions and 9 deletions

View File

@ -61,7 +61,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 ForkTestDefinition(t.name, t.fingerprint) t => new ForkTestDefinition(t.name, t.fingerprint, t.explicitlySpecified, t.selectors)
}.toArray }.toArray
os.writeObject(testsFiltered) os.writeObject(testsFiltered)

View File

@ -42,14 +42,21 @@ public class ForkMain {
public static class ForkTestDefinition implements Serializable { public static class ForkTestDefinition implements Serializable {
public String name; public String name;
public Fingerprint fingerprint; public Fingerprint fingerprint;
public boolean explicitlySpecified;
public Selector[] selectors;
public ForkTestDefinition(String name, Fingerprint fingerprint) { public ForkTestDefinition(String name, Fingerprint fingerprint, boolean explicitlySpecified, Selector[] selectors) {
this.name = name; this.name = name;
if (fingerprint instanceof SubclassFingerprint) { if (fingerprint instanceof SubclassFingerprint) {
this.fingerprint = new SubclassFingerscan((SubclassFingerprint) fingerprint); this.fingerprint = new SubclassFingerscan((SubclassFingerprint) fingerprint);
} else { } else {
this.fingerprint = new AnnotatedFingerscan((AnnotatedFingerprint) fingerprint); this.fingerprint = new AnnotatedFingerscan((AnnotatedFingerprint) fingerprint);
} }
this.explicitlySpecified = explicitlySpecified;
int length = selectors.length;
this.selectors = new Selector[length];
for (int i = 0; i < length; i++)
this.selectors[i] = forkSelector(selectors[i]);
} }
} }
static class ForkError extends Exception { static class ForkError extends Exception {
@ -64,6 +71,13 @@ public class ForkMain {
public Exception getCause() { return cause; } public Exception getCause() { return cause; }
} }
static Selector forkSelector(Selector selector) {
if (selector instanceof Serializable)
return selector;
else
throw new UnsupportedOperationException("Selector implementation must be Serializable, but " + selector.getClass().getName() + " is not.");
}
static class ForkEvent implements Event, Serializable { static class ForkEvent implements Event, Serializable {
private String fullyQualifiedName; private String fullyQualifiedName;
private Fingerprint fingerprint; private Fingerprint fingerprint;
@ -93,12 +107,6 @@ public class ForkMain {
public Status status() { return status; } public Status status() { return status; }
public OptionalThrowable throwable() { return throwable; } public OptionalThrowable throwable() { return throwable; }
public long duration() { return duration; } public long duration() { return duration; }
protected Selector forkSelector(Selector selector) {
if (selector instanceof Serializable)
return selector;
else
throw new UnsupportedOperationException("Selector implementation must be Serializable.");
}
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Socket socket = new Socket(InetAddress.getByName(null), Integer.valueOf(args[0])); Socket socket = new Socket(InetAddress.getByName(null), Integer.valueOf(args[0]));
@ -190,7 +198,7 @@ public class ForkMain {
for (ForkTestDefinition test : tests) { for (ForkTestDefinition test : tests) {
// TODO: To pass in correct explicitlySpecified and selectors // TODO: To pass in correct explicitlySpecified and selectors
if (matches(testFingerprint, test.fingerprint)) if (matches(testFingerprint, test.fingerprint))
filteredTests.add(new TaskDef(test.name, test.fingerprint, false, new Selector[] { new SuiteSelector() })); filteredTests.add(new TaskDef(test.name, test.fingerprint, test.explicitlySpecified, test.selectors));
} }
} }
final Runner runner = framework.runner(frameworkArgs, remoteFrameworkArgs, getClass().getClassLoader()); final Runner runner = framework.runner(frameworkArgs, remoteFrameworkArgs, getClass().getClassLoader());