Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Update abstract tests - #62

Merged
ctrueden merged 2 commits into
mainfrom
update-abstract-tests
Oct 18, 2022
Merged

ctrueden merged 2 commits into
mainfrom
update-abstract-tests

Conversation

@hinerm

@hinerm hinerm commented Sep 21, 2022 •

Copy link
Copy Markdown
Member

The net.imagej.ops2.features package exists only in the test scope, thus
it is not exported in the source module-info.java. This made tests
using that package (any feature test) unusable in Eclipse, for example.

This commit works around the issue by moving the AbstractFeatureTest to
the base net.imagej.ops2 directory, which is already being exported.
* The static helper methods all include the name "Relative" to
  differentiate them from the non-static methods.
* Added a non-static unsigned byte opener
* Unsigned byte method naming is now consistent
@hinerm
hinerm requested review from ctrueden and gselzer September 21, 2022 17:08
@hinerm
hinerm marked this pull request as ready for review September 21, 2022 17:32

@gselzer gselzer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making changes @hinerm!

I don't have much of a problem with the individual changes, and I appreciate that you did the minimum to make the build work.

I am a bit concerned, though, about the idea of putting all of the abstract tests in the top-level folder. My main concern is that this practice will likely conflict with the subpackage dependency rule reinstated in #59, so conforming this rule will limit what we do with abstract classes in tests. But, I didn't see anything in this PR that would break the rules...

I also dislike the fact that we have to make this change for an IDE. I don't think I've had this issue in IntelliJ. Is there any way we could use --patch-module in the Eclipse configuration?

Here is how surefire patches the module

@ctrueden

Copy link
Copy Markdown
Member

@gselzer I agree that this change is unfortunate, but it gets the build passing, and we need that now. How about this plan:

@gselzer

gselzer commented Sep 21, 2022

Copy link
Copy Markdown
Member

I agree that this change is unfortunate, but it gets the build passing, and we need that now

Well, the build is passing, just not in Eclipse.

How about this plan

That sounds fine, but are we really sure that the correct fix will take so long to implement? It seems like you could just do something like this; if that works, is there some way that we could save those args as state somewhere in JPMS projects?

@hinerm

hinerm commented Sep 22, 2022

Copy link
Copy Markdown
Member Author

Well, the build is passing, just not in Eclipse.

It's unfortunate that it works in IntelliJ and not Eclipse, but I do think we should strive for IDE compatibility.

My main concern is that this practice will likely conflict with the subpackage dependency rule reinstated in #59, so conforming this rule will limit what we do with abstract classes in tests.

Understandable. I checked out #59 and tested and confirmed these changes still pass there. I think that if you have a series of (sub)packages, a.b.c.. then I am not sure what scenario could arise that would be a problem that wouldn't also be problematic with b folded into a... e.g. a circular dependency between b and c would be a problem regardless right?

Also I like having the AbstractFeatureTest in the common, high-level ops2 package since it is also extended by classes outside of the features package (i.e. PolygonFeatureTest in the geom subpackage).

That sounds fine, but are we really sure that the correct fix will take so long to implement?

If it was for production code then I think it would be worth more investigation, but since it's just the tests and just for running manually in Eclipse I think we will get very minimal return on time invested, until a point where there is a demonstrable need to have AbstractFeatureTest in a distinct subpackage. I would be strongly against any mechanism that requires passing around eclipse configuration files or the equivalent, and my assumption is something like that would be required to add VM params to the run configurations automatically.

@hinerm

hinerm commented Oct 18, 2022

Copy link
Copy Markdown
Member Author

Well, the build is passing, just not in Eclipse.

@gselzer the tests also do not work for me in IntelliJ. On main @ a245ba7 I get a:

java.lang.reflect.InaccessibleObjectException: Unable to make public void net.imagej.ops2.features.AbstractFeatureTest.setup() accessible: module net.imagej.ops2 does not "exports net.imagej.ops2.features" to unnamed module @10163d6

which goes away with this patch.

@ctrueden do you have any objections or can we merge?

@ctrueden ctrueden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a step forward for immediate development. We always have the flexibility to refactor any test-scope classes and packages; we're not boxing ourselves into any corners design-wise.

@ctrueden
ctrueden merged commit eaa8d43 into main Oct 18, 2022
@ctrueden
ctrueden deleted the update-abstract-tests branch October 18, 2022 17:47
@hinerm

hinerm commented Oct 18, 2022

Copy link
Copy Markdown
Member Author

oh good* news, Tamura2dFeatureTest still fails for me in IntelliJ with this branch, it just gives different error messages whether its run individually (see above error) or as part of "All Tests" from the imagej-ops2 component, with:

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 10000 out of bounds for length 10000

Everything passes from the command line. ☠️

*I've chosen to contextualize bad news as good news

@gselzer

gselzer commented Oct 18, 2022 •

Copy link
Copy Markdown
Member

@ctrueden said:

This is a step forward for immediate development. We always have the flexibility to refactor any test-scope classes and packages; we're not boxing ourselves into any corners design-wise.

Yes, good point. Thank you both for working on this!

@hinerm said:

oh good* news, Tamura2dFeatureTest still fails for me in IntelliJ with this branch, it just gives different error messages whether its run individually (see above error) or as part of "All Tests" from the imagej-ops2 component, with:

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 10000 out of bounds for length 10000

I'm pretty certain this is a bug in imglib2's LoopBuilder. I asked @maarzt about it at some point on Gitter, I'll try to find it.

EDIT: Found it

@hinerm

hinerm commented Oct 18, 2022

Copy link
Copy Markdown
Member Author

and I think I was wrong.. I cleaned and re-ran everything and the exception is consistently the AIOOBE it looks like. Yay!

@gselzer

gselzer commented Oct 18, 2022

Copy link
Copy Markdown
Member

and I think I was wrong.. I cleaned and re-ran everything and the exception is consistently the AIOOBE it looks like. Yay!

It's a shame that nobody (including myself) made progress on that bug, as far as I can remember. Not even an issue in imglib2...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eclipse: Abstract test superclasses in test-only packages are not exported by JPMS

3 participants