Skip to content

Commit

Permalink
Fixed newer versions of uTest hanging because of asynchronous test la…
Browse files Browse the repository at this point in the history
…unch
  • Loading branch information
jamesbrain committed Sep 4, 2015
1 parent 3cb00ff commit f804d16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
Expand Up @@ -28,7 +28,6 @@ public UTestReporter(int classCount) {
private AtomicInteger idHolder = new AtomicInteger();
private final Map<UTestPath, Integer> testPathToId = new HashMap<UTestPath, Integer>();
private final Map<String, Integer> fqnToMethodCount = new HashMap<String, Integer>();
private final Map<UTestPath, List<UTestPath>> testToAncestors = new HashMap<UTestPath, List<UTestPath>>();
private final Map<UTestPath, Integer> testToClosedChildren = new HashMap<UTestPath, Integer>();

protected int getNextId() {
Expand Down Expand Up @@ -68,7 +67,7 @@ public void reportStarted(UTestPath testPath, boolean isScope) {
reportStartedInner(testName, id, parentId, getLocationHint(testPath.getQualifiedClassName(), testPath.getMethod(), testName), isScope);
} else {
if (!isStarted(parent)) {
openAncestors(testPath);
reportStarted(parent, true);
}
int parentId = testPathToId.get(parent);
int id = getNextId();
Expand All @@ -77,23 +76,6 @@ public void reportStarted(UTestPath testPath, boolean isScope) {
}
}

private void openAncestors(UTestPath start) {
List<UTestPath> ancestors = new LinkedList<UTestPath>();
UTestPath parent = start.parent();
do {
ancestors.add(parent);
parent = parent.parent();
} while (parent != null && !isStarted(parent));
Collections.reverse(ancestors);
//now, open scopes for all the ancestors
for (UTestPath ancestor: ancestors) {
reportStarted(ancestor, true);
}
Collections.reverse(ancestors);
testToAncestors.put(start, ancestors);
}


public void reportFinished(UTestPath testPath, Result result, boolean isScope,
Map<UTestPath, Integer> childrenCount) {

Expand Down Expand Up @@ -130,13 +112,7 @@ public void reportFinished(UTestPath testPath, Result result, boolean isScope,
reportScopeOrTestFinished(testPath, isScope, result);
}
}
//now, close all the dummy scopes that can not be closed by a separate reportFinished call
List<UTestPath> ancestors = testToAncestors.get(testPath);
if (ancestors != null) {
for (UTestPath ancestor: ancestors) {
reportFinished(ancestor, null, true, childrenCount);
}
} else {
if (parent != null) {
reportFinished(parent, null, true, childrenCount);
}
}
Expand Down
Expand Up @@ -5,7 +5,6 @@
import scala.collection.*;
import scala.collection.immutable.Nil$;
import scala.collection.mutable.Buffer;
import scala.concurrent.ExecutionContext;
import scala.concurrent.Future$;
import scala.runtime.BoxedUnit;
import utest.framework.Result;
Expand All @@ -21,8 +20,6 @@
import java.util.Map;
import java.util.Set;

import static org.jetbrains.plugins.scala.testingSupport.TestRunnerUtil.escapeString;

public class UTestRunner {

private static UTestPath parseTestPath(String className, String argsString) {
Expand Down Expand Up @@ -103,7 +100,9 @@ public BoxedUnit apply(Seq < String > seq, Result result) {
UTestPath resTestPath = testPath.append(resSeq);
boolean isLeafTest = leafTests.contains(resTestPath);

reporter.reportFinished(resTestPath, result, !isLeafTest, childrenCount);
if (leafTests.contains(resTestPath)) {
reporter.reportFinished(resTestPath, result, !isLeafTest, childrenCount);
}
return BoxedUnit.UNIT;
}
}
Expand All @@ -112,7 +111,7 @@ public BoxedUnit apply(Seq < String > seq, Result result) {
try {
runAsyncMethod.invoke(testTree, reportFunction, path, Nil$.MODULE$,
runAsyncMethod.getName().equals("runAsync") ? Option.empty() : Future$.MODULE$.successful(Option.empty()),
ExecutionContext.Implicits$.MODULE$.global());
utest.ExecutionContext.RunNow$.MODULE$);
} catch (IllegalAccessException e) {
System.out.println(errorMessage + e);
} catch (InvocationTargetException e) {
Expand Down

0 comments on commit f804d16

Please sign in to comment.