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

JUnit Plug-in tests cannot be started if an older target platform is used #733

Closed
vogella opened this issue Sep 6, 2023 · 7 comments · Fixed by #765
Closed

JUnit Plug-in tests cannot be started if an older target platform is used #733

vogella opened this issue Sep 6, 2023 · 7 comments · Fixed by #765

Comments

@vogella
Copy link
Contributor

vogella commented Sep 6, 2023

If I use

<repository location="https://download.eclipse.org/eclipse/updates/4.6"/> 

PDE plug-in tests will not work with the following error message:

!ENTRY org.eclipse.pde.junit.runtime 4 0 2023-09-06 08:20:51.713
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.pde.junit.runtime [97]
  Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.29.0,4.0.0)"
  Unresolved requirement: Require-Bundle: org.eclipse.jdt.junit.runtime; bundle-version="[3.5.0,4.0.0)"
    -> Bundle-SymbolicName: org.eclipse.jdt.junit.runtime; bundle-version="3.7.200.v20230627-0107"; singleton:="true"
       org.eclipse.jdt.junit.runtime [91]
         Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))"

	at org.eclipse.osgi.container.Module.start(Module.java:444)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1599)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

If I switch to a recent release, like I can start JUnit Plug-in tests.

			<repository location="https://download.eclipse.org/releases/2023-09"/>

Full target platform:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="eclipse4.6">
	<locations>
		<location includeAllPlatforms="true" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
			<repository location="https://download.eclipse.org/eclipse/updates/4.6"/>
			<!--
			Use this one to run Junit plug-in tests
			<repository location="https://download.eclipse.org/releases/2023-09"/>
			-->
			<unit id="org.eclipse.e4.rcp.feature.group" version="0.0.0"/>
			<unit id="org.eclipse.rcp.feature.group" version="0.0.0"/>
			<unit id="org.eclipse.equinox.core.feature.feature.group" version="0.0.0"/>
			<unit id="org.junit" version="0.0.0"/>
			<unit id="org.apache.ant" version="0.0.0"/>
		</location>
	</locations>
</target>

Is it expected that the target platform influences the ability to execute JUnit Plug-in tests?

@vogella vogella changed the title PDE Junit test runner complains that dependencies are not met if JUnit Plug-in tests cannot be started if an older target platform is used Sep 6, 2023
@HannesWell
Copy link
Member

org.osgi.framework.BundleException: Could not resolve module: org.eclipse.pde.junit.runtime [97]
  Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.29.0,4.0.0)"
  Unresolved requirement: Require-Bundle: org.eclipse.jdt.junit.runtime; bundle-version="[3.5.0,4.0.0)"
    -> Bundle-SymbolicName: org.eclipse.jdt.junit.runtime; bundle-version="3.7.200.v20230627-0107"; singleton:="true"
       org.eclipse.jdt.junit.runtime [91]
         Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))"

From this error message I assume that you start your test-runtime with a JRE below Java-11?
PDE has some tricks built in when it starts JUnit Plugin tests where it adds org.eclipse.pde.junit.runtime and maybe a few other test-support bundles from the Installation if they are not present in the Target-Platform.
Maybe we should be more careful with those special bundles and make them compatible with older Java-releases if that's desired.

As a workaround it would probably be sufficient to add org.eclipse.pde.junit.runtime as unit to your target-platform so that the version from that released is available and can be included in the Test-Runtime.

@vogella
Copy link
Contributor Author

vogella commented Sep 12, 2023

Thanks @HannesWell I will give this a try.

@vogella
Copy link
Contributor Author

vogella commented Sep 19, 2023

The issue is also present with a Java 17 runtime, I just had this issue with the second client. Adding org.eclipse.pde.junit.runtime to the target platform helps. Easy to reproduce, just do not include the pde.junit.runtime into your target platform and you will not be able to run PDE JUnit tests anymore.

@HannesWell
Copy link
Member

With a Java-17 runtime probably the first Missing requirement remains:

org.osgi.framework.BundleException: Could not resolve module: org.eclipse.pde.junit.runtime [97]
  Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.29.0,4.0.0)"

I see options:

  1. Require only an older version of o.e.core.runtime
  2. Include the entire dependency closure of pde.junit.runtime.

The first option is difficult to ensure with confidence since we (at least currently) have no tests for that and the question would be which would be the oldest supported version.
On the other hand option two would be relativly simple to implementat but could 'pollute' the runtime with many duplicats and more recent version bundels than one would expect. It would probably even add a second o.e.osgi system bundle. In general this could lead to subtile differences that lead to difficult to recognise bugs and false positive or false negative result.

Therefore option one would actually be the saver and cleaner one.

@merks
Copy link
Contributor

merks commented Sep 20, 2023

I agree with this assessment. The bound was only changed for "our safety and comfort" but while it might be safe, it turns out not to be comfortable...

@HannesWell
Copy link
Member

I just created #765 to lower it.
The Plugin compiled successfully with Java-1.8 and a Eclipse Juno TP without any effort.

@vogella
Copy link
Contributor Author

vogella commented Sep 26, 2023

Awesome @HannesWell this will be very useful for my clients (once they upgrade, I don't think they are willing to use I-Builds).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants