Skip to content

Commit

Permalink
Merge pull request quarkusio#17833 from stuartwdouglas/test-output
Browse files Browse the repository at this point in the history
Improve mvn quarkus:test output
  • Loading branch information
stuartwdouglas authored Jun 11, 2021
2 parents 6983ad5 + 14ca92c commit f319507
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.quarkus.bootstrap.app.AugmentAction;
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.runner.Timing;
import io.quarkus.deployment.builditem.ConsoleFormatterBannerBuildItem;
import io.quarkus.deployment.dev.testing.TestHandler;
import io.quarkus.deployment.dev.testing.TestSetupBuildItem;
import io.quarkus.deployment.dev.testing.TestSupport;
Expand All @@ -25,7 +26,6 @@
import io.quarkus.dev.spi.DevModeType;
import io.quarkus.dev.spi.HotReplacementSetup;
import io.quarkus.runner.bootstrap.AugmentActionImpl;
import io.quarkus.runtime.logging.LoggingSetupRecorder;

/**
* The main entry point of quarkus:test
Expand All @@ -41,6 +41,7 @@ public class IsolatedTestModeMain extends IsolatedDevModeMain {

private RuntimeUpdatesProcessor setupRuntimeCompilation(DevModeContext context, Path applicationRoot)
throws Exception {
System.setProperty("quarkus.test.display-test-output", "true");
if (!context.getAllModules().isEmpty()) {
ServiceLoader<CompilationProvider> serviceLoader = ServiceLoader.load(CompilationProvider.class);
List<CompilationProvider> compilationProviders = new ArrayList<>();
Expand Down Expand Up @@ -125,16 +126,13 @@ public void accept(CuratedApplication o, Map<String, Object> params) {
}
try {
augmentAction.performCustomBuild(TestHandler.class.getName(), null, TestSetupBuildItem.class.getName(),
LoggingSetupBuildItem.class.getName());
LoggingSetupBuildItem.class.getName(), ConsoleFormatterBannerBuildItem.class.getName());
} catch (Throwable t) {
//logging may not have been started, this is more reliable
System.err.println("Failed to start quarkus test mode");
t.printStackTrace();
System.exit(1);
}
//we don't actually start the app
//so logging would not be enabled
LoggingSetupRecorder.handleFailedStart();

Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@

import java.util.function.BiConsumer;

import org.jboss.logging.Logger;

import io.quarkus.banner.BannerConfig;
import io.quarkus.builder.BuildResult;
import io.quarkus.deployment.steps.BannerProcessor;
import io.quarkus.dev.console.QuarkusConsole;
import io.quarkus.runtime.BannerRecorder;
import io.quarkus.runtime.BannerRuntimeConfig;
import io.quarkus.runtime.configuration.ConfigInstantiator;
import io.quarkus.runtime.logging.LoggingSetupRecorder;

public class TestHandler implements BiConsumer<Object, BuildResult> {
@Override
public void accept(Object o, BuildResult buildResult) {
QuarkusConsole.start();
TestSupport.instance().get().start();

//we don't actually start the app
//so logging would not be enabled
BannerConfig bannerConfig = new BannerConfig();
BannerRuntimeConfig bannerRuntimeConfig = new BannerRuntimeConfig();
ConfigInstantiator.handleObject(bannerConfig);
ConfigInstantiator.handleObject(bannerRuntimeConfig);
LoggingSetupRecorder.handleFailedStart(new BannerProcessor()
.recordBanner(new BannerRecorder(), bannerConfig, bannerRuntimeConfig).getBannerSupplier());
Logger.getLogger("io.quarkus.test").info("Quarkus continuous testing mode started");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ public LoggingSetupRecorder() {

@SuppressWarnings("unused") //called via reflection, as it is in an isolated CL
public static void handleFailedStart() {
handleFailedStart(new RuntimeValue<>(Optional.empty()));
}

public static void handleFailedStart(RuntimeValue<Optional<Supplier<String>>> banner) {
LogConfig config = new LogConfig();
ConfigInstantiator.handleObject(config);
LogBuildTimeConfig buildConfig = new LogBuildTimeConfig();
ConfigInstantiator.handleObject(buildConfig);
new LoggingSetupRecorder().initializeLogging(config, buildConfig, Collections.emptyList(), Collections.emptyList(),
Collections.emptyList(), null);
Collections.emptyList(), banner);
}

public void initializeLogging(LogConfig config, LogBuildTimeConfig buildConfig,
Expand Down

0 comments on commit f319507

Please sign in to comment.