Bug 550557 - Unable to run junit tests from context menu
Summary: Unable to run junit tests from context menu
Status: RESOLVED INVALID
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.9   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 4.14 M3   Edit
Assignee: Vikas Chandra CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-29 05:29 EDT by Sravan Kumar Lakkimsetti CLA
Modified: 2020-01-21 05:08 EST (History)
10 users (show)

See Also:


Attachments
stack trace (2.50 KB, text/plain)
2019-08-29 05:29 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
smaller swt test suite (39.28 KB, application/zip)
2019-08-29 08:27 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sravan Kumar Lakkimsetti CLA 2019-08-29 05:29:50 EDT
Created attachment 279706 [details]
stack trace

While attempting to run junit tests from context menu, they were not getting launched throwing the attached stack trace.

On second attempt they do get launched.

Steps to reproduce
1. clone http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/tests into local machine using git
2. Launch eclipse with fresh workspace
3. Import org.eclipse.swt.tests project using import->Existing projects into workspace
4. Run http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/tests/org.eclipse.swt.tests/JUnit%20Tests/org/eclipse/swt/tests/junit/AllTests.java as junit test

Junit tests do not get launched here throwing attached stack trace in error log. If you try again they do get launched
Comment 1 Andrey Loskutov CLA 2019-08-29 05:38:51 EDT
Looks like a problem with debug launch trying to build with a wrong rule.
Comment 2 Dani Megert CLA 2019-08-29 05:50:29 EDT
Sravan, can you provide the exact steps? Also which build and is it a regression compared to 4.12?
Comment 3 Sravan Kumar Lakkimsetti CLA 2019-08-29 05:57:59 EDT
(In reply to Dani Megert from comment #2)
> Sravan, can you provide the exact steps? Also which build and is it a
> regression compared to 4.12?

Build Info:
eclipse.buildId=4.13.0.I20190828-1800
java.version=12.0.2
java.vendor=AdoptOpenJDK
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64

I will try and get a simpler use case and update the bug.
Comment 4 Sarika Sinha CLA 2019-08-29 06:02:50 EDT
(In reply to Andrey Loskutov from comment #1)
> Looks like a problem with debug launch trying to build with a wrong rule.

I will check but not aware of any rule change for Project build.

@Michael,
Do you remember any change from Job rule perspective?
Comment 5 Andrey Loskutov CLA 2019-08-29 06:06:44 EDT
(In reply to Sarika Sinha from comment #4)
> (In reply to Andrey Loskutov from comment #1)
> > Looks like a problem with debug launch trying to build with a wrong rule.
> 
> I will check but not aware of any rule change for Project build.

I have no IDE at hand right now, so this was my first guess. Usually the build job takes the "right" rule for the resources to be built, therefore my assumption was that we made some mistake in debug launcher and run this task in a job with incompatible "outer" rule.
Comment 6 Andrey Loskutov CLA 2019-08-29 06:12:43 EDT
However you're right, the message is strange, the build job uses empty? multi-rule:
"Attempted to beginRule: MultiRule[], does not match outer scope rule: R/". 
What? In which case build manager computes an empty rule for building? 
Simeon, can you please check? I can't remember that we changed something related in resources, but who knows, may be some optimization broke something?
Comment 7 Sravan Kumar Lakkimsetti CLA 2019-08-29 06:25:21 EDT
Its a regression from 4.8. I can see this problem from 4.9
Comment 8 Mickael Istria CLA 2019-08-29 06:29:47 EDT
> Its a regression from 4.8. I can see this problem from 4.9

So most likely something related to parallel builds then.

(In reply to Andrey Loskutov from comment #6)
> "Attempted to beginRule: MultiRule[], does not match outer scope rule: R/". 
> What? In which case build manager computes an empty rule for building? 
> Simeon, can you please check? I can't remember that we changed something
> related in resources, but who knows, may be some optimization broke
> something?

Yes, the empty multi-rule is a bad smell, especially after a project.build(), the current rule should at least be the current project...
Also, another smell about MultiRule is shouldn't an empty multi-rule basically be a match for any other ISchedulingRule (ie empty multirule be equivalent to no rule)?
Comment 9 Sravan Kumar Lakkimsetti CLA 2019-08-29 08:27:10 EDT
Created attachment 279714 [details]
smaller swt test suite

Steps to reproduce
1. Start eclipse any version from 4.9 (Any java version is fine) with new workspace
2. Open error log view
3. Import attached project (you'll see "Attempted to beginRule: MultiRule[], does not match outer scope rule: R/" in the error log)
4. Try to run AllWidgetTests.java as junit test. (it doesn't start and you'll see same error message as step 3 in error log)
5. Try to run the tests again. This time tests will launch
Comment 10 Noopur Gupta CLA 2019-08-29 08:31:18 EDT
Reproducible on Windows 10 also.
Comment 11 Sravan Kumar Lakkimsetti CLA 2019-08-29 08:37:31 EDT
Reproducible on Mac 10.14
Comment 12 Simeon Andreev CLA 2019-08-29 09:03:14 EDT
Andrey, our rule problems were due to a workspace residing in a git repository. This doesn't seem to be the case here.

Builders with empty rules that I see so far: 

* org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker (when building)
* org.eclipse.pde.internal.core.builders.ExtensionPointSchemaBuilder (when running the JUnit test and when building)

For the ManifestConsistencyChecker, the rule is returned due to:

org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.getRule(int, Map<String, String>)

	@Override
	public ISchedulingRule getRule(int kind, Map<String, String> args) {
		return new MultiRule(Arrays.stream(getProject().getWorkspace().getRoot().getProjects())
				.filter(PDEBuilderHelper::isPDEProject).toArray(ISchedulingRule[]::new));
	}

For the ExtensionPointSchemaBuilder, similar code in org.eclipse.pde.internal.core.builders.ExtensionPointSchemaBuilder.getRule(int, Map<String, String>):

	@Override
	public ISchedulingRule getRule(int kind, Map<String, String> args) {
		return new MultiRule(Arrays.stream(getProject().getWorkspace().getRoot().getProjects())
				.filter(PDEBuilderHelper::isPDEProject)
				.toArray(ISchedulingRule[]::new));
	}

isPDEProject implementation:

		return project != null && project.isAccessible()
				&& (PDE.hasPluginNature(project) || PDE.hasFeatureNature(project) || PDE.hasUpdateSiteNature(project));

The attached project has only 1 nature:

	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>

But has builders:

		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.pde.ManifestBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.pde.SchemaBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>

I'm guessing, not nice that PDE behaves poorly in such situations, but the attached project seems to be misconfigured, so not really PDE to blame?
Comment 13 Mickael Istria CLA 2019-08-29 10:55:08 EDT
> Its a regression from 4.8. I can see this problem from 4.9

So most likely something related to parallel builds then (that's demonstrated later by Simeon)

(In reply to Andrey Loskutov from comment #6)
> "Attempted to beginRule: MultiRule[], does not match outer scope rule: R/". 
> What? In which case build manager computes an empty rule for building? 
> Simeon, can you please check? I can't remember that we changed something
> related in resources, but who knows, may be some optimization broke
> something?

Yes, the empty multi-rule is a bad smell, especially after a project.build(), the current rule should at least be the current project...
Also, another smell about MultiRule is shouldn't an empty multi-rule basically be a match for any other ISchedulingRule (ie empty multirule be equivalent to no rule)?

(In reply to Simeon Andreev from comment #12)
> * org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker (when
> building)
> * org.eclipse.pde.internal.core.builders.ExtensionPointSchemaBuilder (when
> running the JUnit test and when building)
> [...]
>
> 	@Override
> 	public ISchedulingRule getRule(int kind, Map<String, String> args) {
> 		return new
> MultiRule(*somePossibleEmptyStream*.toArray(ISchedulingRule[]::new));
> 	}
>
> I'm guessing, not nice that PDE behaves poorly in such situations

Right, the builders should probably return either null or getProject() as scheduling rule in that case.

> but the
> attached project seems to be misconfigured, so not really PDE to blame?

The project indeed seems misconfigured, so while PDE is to blame, I don't think it's worth the trouble of fixing it in RC2.
Comment 14 Sarika Sinha CLA 2019-08-29 12:59:41 EDT
Moving to PDE based on the comments.
Comment 15 Dani Megert CLA 2019-10-16 08:39:13 EDT
What's the status here? Please don't make this a ping-pong match.
Comment 16 Vikas Chandra CLA 2019-11-07 02:18:21 EST
Thanks  Simeon Andreev.

I investigated this and found the same conclusion. The project is grossly misconfigured.

It has PDE builders but no pde nature. Either PDE builders should be removed or PDE nature should be added. How did project end up in this state?

Trying to fix something in a project with inconsistent state doesn't make any sense. 

Closing this as invalid !