Skip to content

Commit

Permalink
swtbot: Print user instructions to enable SLF4J logging
Browse files Browse the repository at this point in the history
Change-Id: I115be05e8cc9d608e5657826e4ad997ec5dd02f9
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/205303
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
PatrickTasse committed Nov 3, 2023
1 parent 76f0fe7 commit 97835fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -42,7 +42,8 @@ Import-Package: com.google.common.base,
org.eclipse.tracecompass.testtraces.ctf,
org.eclipse.tracecompass.tmf.ctf.core.tests.shared,
org.eclipse.tracecompass.tmf.ctf.core.trace,
org.slf4j
org.slf4j,
org.slf4j.helpers
Export-Package: org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom;x-internal:=true,
org.eclipse.tracecompass.tmf.ui.swtbot.tests.perf.views,
org.eclipse.tracecompass.tmf.ui.swtbot.tests.perspectives;x-internal:=true,
Expand Down
Expand Up @@ -125,8 +125,10 @@
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.handlers.IHandlerService;
import org.hamcrest.Matcher;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.NOPLoggerFactory;

import com.google.common.collect.Lists;

Expand Down Expand Up @@ -421,6 +423,7 @@ public void run() {
* Initialize the environment for SWTBot
*/
public static void initialize() {
checkLogger();
failIfUIThread();

SWTWorkbenchBot bot = new SWTWorkbenchBot();
Expand Down Expand Up @@ -495,6 +498,18 @@ private static void printEnvironment() {
fPrintedEnvironment = true;
}

/**
* Check if the SLF4J logger is activated
*/
private static void checkLogger() {
ILoggerFactory factory = LoggerFactory.getILoggerFactory();
if (factory instanceof NOPLoggerFactory) {
System.err.println("SLF4J binding not active. To enable logging, set Auto-Start to true");
System.err.println("for org.apache.aries.spifly.dynamic.bundle and slf4j.simple in the");
System.err.println("Plug-ins tab of your JUnit Plug-in Test's Run/Debug Configuration.");
}
}

/**
* If the test is running in the UI thread then fail
*/
Expand Down

0 comments on commit 97835fc

Please sign in to comment.