Skip to content

Commit

Permalink
work?
Browse files Browse the repository at this point in the history
  • Loading branch information
J3fftw1 committed Nov 21, 2023
1 parent c0e792e commit b2cfe69
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -70,47 +71,36 @@ public void runTests(@Nonnull String packageName) {
boolean threadSafe = annotation.threadSafe();

CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean failed = new AtomicBoolean(false);

// Invoke
try {
testsRan++;
logMessage("run test: " + method.getName());

method.setAccessible(true);
Object instance = method.getDeclaringClass().getDeclaredConstructor().newInstance();
if (threadSafe) {
logMessage("we are safe no question");
method.invoke(instance);
} else {
logMessage("we arent safe");
Bukkit.getScheduler().runTask(E2ETester.getInstance(), () -> {
try {
logMessage("before invocation");
method.invoke(instance);
logMessage("after invocation");
latch.countDown();
} catch (IllegalAccessException | InvocationTargetException e) {
latch.countDown();
logMessage("caught exception");
if (e.getCause() instanceof TestFailException) {
logMessage("test fail exception");
testsFailed++;
logMessage(" x %s", description);
e.printStackTrace();
} else {
testsFailed++;
logMessage(" x %s", description);
e.printStackTrace();
failed.set(true);
}
}
});
logMessage("we are waiting");
latch.await();
logMessage("we are finished waiting");
}

testsPassed++;
logMessage(" ✔ %s", description);
if (failed.get()) {
testsFailed++;
logMessage(" x %s", description);
} else {
testsPassed++;
logMessage(" ✔ %s", description);
}
} catch(TestFailException e) {
testsFailed++;
logMessage(" x %s", description);
Expand Down

0 comments on commit b2cfe69

Please sign in to comment.