From 603f4944867fe32b2e55b448019c4470c566d61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 23 Jun 2025 15:17:54 +0200 Subject: [PATCH 1/2] Print framework state on failing bundles If plugin test do not work as expected the user is currently quite blind. At best there is an exception in the log about a failing bundle, at worst there is only a message "No tests found" and then nothing is executed at all. This now first checks if there are any unresolved plugins and print the current bundles and their state if anything is failing, and also makes the additional manifest to use non optional imports as otherwise things are possibly missing. --- .../junit/runtime/RemotePluginTestRunner.java | 46 +++++++++++++++++++ .../JUnitLaunchConfigurationDelegate.java | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/RemotePluginTestRunner.java b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/RemotePluginTestRunner.java index ab87c59cd62..fcedfd3d0a7 100644 --- a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/RemotePluginTestRunner.java +++ b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/RemotePluginTestRunner.java @@ -72,6 +72,34 @@ protected Enumeration findResources(String name) throws IOException { * @see RemoteTestRunner */ public static void main(String[] args) { + BundleContext bundleContext = FrameworkUtil.getBundle(RemotePluginTestRunner.class).getBundleContext(); + if (bundleContext != null) { + Bundle[] bundles = bundleContext.getBundles(); + int failures = 0; + for (Bundle bundle : bundles) { + int state = bundle.getState(); + if (state != Bundle.ACTIVE && state != Bundle.RESOLVED && state != Bundle.STARTING) { + if (failures == 0) { + System.err.println("##################################################"); //$NON-NLS-1$ + System.out.println(); + System.err.println("WARNING: There are failing bundles:"); //$NON-NLS-1$ + } + System.err.println(String.format(" %s %s can't be resolved!", bundle.getSymbolicName(), bundle.getVersion())); //$NON-NLS-1$ + failures++; + } + } + if (failures > 0) { + System.err.println(); + System.err.println("Current Framework state is:"); //$NON-NLS-1$ + for (Bundle bundle : bundles) { + System.err.println(String.format(" [%s][%d] %s %s", getState(bundle.getState()), bundle.getBundleId(), bundle.getSymbolicName(), bundle.getVersion())); //$NON-NLS-1$ + } + System.err.println(); + System.err.println(String.format("%d bundle(s) fail to resolve!", failures)); //$NON-NLS-1$ + System.out.println(); + System.err.println("##################################################"); //$NON-NLS-1$ + } + } RemotePluginTestRunner testRunner = new RemotePluginTestRunner(); testRunner.init(args); ClassLoader currentTCCL = Thread.currentThread().getContextClassLoader(); @@ -86,6 +114,24 @@ public static void main(String[] args) { } } + private static String getState(int state) { + switch (state) { + case Bundle.ACTIVE : + return "ACTIVE "; //$NON-NLS-1$ + case Bundle.INSTALLED : + return "INSTALLED "; //$NON-NLS-1$ + case Bundle.RESOLVED : + return "RESOLVED "; //$NON-NLS-1$ + case Bundle.STARTING : + return "STARTING "; //$NON-NLS-1$ + case Bundle.STOPPING : + return "STOPPING "; //$NON-NLS-1$ + case Bundle.UNINSTALLED : + return "UNINSTALLED"; //$NON-NLS-1$ + } + return Integer.toString(state); + } + private static ClassLoader createJUnit5PluginClassLoader(String testPluginName) { Bundle testBundle = Platform.getBundle(testPluginName); if (testBundle == null) { diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java index 6544a6e0bc7..e1524a05bcc 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java @@ -235,7 +235,7 @@ protected void collectExecutionArguments(ILaunchConfiguration configuration, Lis //if this is a junit container project it means a user can use additional classes (from the junit container and possible other) that //are not required to be imported, we compute a fragment manifest here to add additional imports ... try (PdeProjectAnalyzer analyzer = new PdeProjectAnalyzer(javaProject.getProject(), true)) { - analyzer.setImportPackage("*;resolution:=optional"); //$NON-NLS-1$ + analyzer.setImportPackage("*"); //$NON-NLS-1$ String bsn = testPlugin.getId() + "-additional-test-probe-imports"; //$NON-NLS-1$ analyzer.setBundleSymbolicName(bsn); analyzer.set(Constants.FRAGMENT_HOST, testPlugin.getId()); From 7f5bc9cf7ef2cfc494b89075674d1da2f419c454 Mon Sep 17 00:00:00 2001 From: Eclipse PDE Bot Date: Mon, 23 Jun 2025 13:26:30 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.37 stream --- ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF index 35cbed40639..15482f9ed52 100644 --- a/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.junit.runtime; singleton:=true -Bundle-Version: 3.8.100.qualifier +Bundle-Version: 3.8.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.jdt.junit.runtime;bundle-version="[3.4.0,4.0.0)",