Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mvn quarkus:test output #17833

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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