Skip to content

Commit

Permalink
More improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Apr 6, 2021
1 parent 4728311 commit 6381135
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TestConfig {
* Defaults to 'slow'
*/
@ConfigItem(defaultValue = "slow")
public List<String> excludeTags;
public Optional<List<String>> excludeTags;

/**
* Disable the testing status/prompt message at the bottom of the console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public AeshConsole(Connection connection) {
this.connection = connection;
connection.openNonBlocking();
setup(connection);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
connection.close();
}
}, "Console Shutdown Hoot"));
}

private synchronized AeshConsole setStatusMessage(String statusMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void popInputHandler() {

public abstract void write(byte[] buf, int off, int len);

public static void installConsole(TestConfig config) {
public static synchronized void installConsole(TestConfig config) {
if (installed) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ public void quarkusStarting() {

@Override
public void executionStarted(TestIdentifier testIdentifier) {
String className = "";
if (testIdentifier.getSource().isPresent()) {
if (testIdentifier.getSource().get() instanceof MethodSource) {
className = ((MethodSource) testIdentifier.getSource().get()).getClassName();
} else if (testIdentifier.getSource().get() instanceof ClassSource) {
className = ((ClassSource) testIdentifier.getSource().get()).getClassName();
}
}
listener.testStarted(testIdentifier, className);
waitTillResumed();
touchedClasses.push(Collections.synchronizedSet(new HashSet<>()));
}
Expand Down Expand Up @@ -387,9 +396,9 @@ public String apply(Class<?> aClass) {
ClassInfo def = index.getClassByName(DotName.createSimple(aClass.getName()));
AnnotationInstance testProfile = def.classAnnotation(DotName.createSimple("io.quarkus.test.junit.TestProfile"));
if (testProfile == null) {
return "";
return "$$" + aClass.getName();
}
return testProfile.value().asClass().name().toString();
return testProfile.value().asClass().name().toString() + "$$" + aClass.getName();
}
}));
return ret;
Expand All @@ -413,6 +422,7 @@ public interface TestListener {

void runAborted();

void testStarted(TestIdentifier testIdentifier, String className);
}

private class TestLogCapturingHandler implements Predicate<LogRecord> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.jboss.logging.Logger;
import org.junit.platform.engine.TestExecutionResult;
import org.junit.platform.launcher.TestIdentifier;
import org.opentest4j.TestAbortedException;

import io.quarkus.bootstrap.app.CuratedApplication;
Expand Down Expand Up @@ -238,8 +239,6 @@ public void testComplete(TestResult result) {
skipped.incrementAndGet();
}
methodCount.incrementAndGet();
promptHandler.setStatus("Running " + methodCount.get() + "/" + totalNoTests
+ (failureCount.get() == 0 ? "." : ". " + failureCount + " failures so far."));
}

@Override
Expand All @@ -250,6 +249,15 @@ public void runComplete(TestRunResults results) {
@Override
public void runAborted() {
}

@Override
public void testStarted(TestIdentifier testIdentifier, String className) {
promptHandler.setStatus("Running " + methodCount.get() + "/" + totalNoTests
+ (failureCount.get() == 0 ? "."
: ". " + failureCount + " failures so far.")
+ " Running: "
+ className + "#" + testIdentifier.getDisplayName());
}
})
.build();
if (paused) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.function.BiFunction;

import io.quarkus.deployment.IsDevelopment;
import org.jboss.jandex.ClassInfo;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
Expand Down Expand Up @@ -41,10 +42,18 @@ LogCleanupFilterBuildItem handle() {
return new LogCleanupFilterBuildItem("org.junit.platform.launcher.core.EngineDiscoveryOrchestrator", "0 containers");
}

@BuildStep(onlyIf= IsDevelopment.class)
ServiceStartBuildItem setupConsole(TestConfig config) {
if (RuntimeUpdatesProcessor.INSTANCE == null || config.enabled == TestConfig.Mode.DISABLED) {
return null;
}
QuarkusConsole.installConsole(config);
return null;
}

@BuildStep(onlyIfNot = IsNormal.class)
@Produce(LogHandlerBuildItem.class)
ServiceStartBuildItem startTesting(TestConfig config) {
QuarkusConsole.installConsole(config);
if (RuntimeUpdatesProcessor.INSTANCE == null || config.enabled == TestConfig.Mode.DISABLED) {
return null;
}
Expand All @@ -55,7 +64,7 @@ ServiceStartBuildItem startTesting(TestConfig config) {
RuntimeUpdatesProcessor.INSTANCE.getTestSupport().stop();
}
RuntimeUpdatesProcessor.INSTANCE.getTestSupport().setTags(config.includeTags.orElse(Collections.emptyList()),
config.excludeTags);
config.excludeTags.orElse(Collections.emptyList()));
return null;
}

Expand Down
2 changes: 2 additions & 0 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ public void execute() throws MojoFailureException, MojoExecutionException {
if (System.currentTimeMillis() > nextCheck) {
nextCheck = System.currentTimeMillis() + 100;
if (!runner.alive()) {
//reset the terminal
System.out.println("\u001B[0m");
if (runner.exitValue() != 0) {
throw new MojoExecutionException("Dev mode process did not complete successfully");
}
Expand Down

0 comments on commit 6381135

Please sign in to comment.