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

Fix Windows build issues #121

Merged
merged 3 commits into from
Oct 21, 2024
Merged

Fix Windows build issues #121

merged 3 commits into from
Oct 21, 2024

Conversation

ctrueden
Copy link
Contributor

This patch fixes issues with the unit tests on Windows as well as the recent ImgLib2 v7 update. It upgrades to the newly released spim_data version 2.3.4, and also tidies up the SciJava context logic across the codebase to avoid the SingletonContext in favor of contexts with managed lifecycles (i.e. ensuring dispose() gets called at conclusion).

It also escapes any backslashes hardcoded into macros (notably: Windows file paths), to account for ImageJ macro using backslash as an escape character.

With these changes, all tests on Windows now pass, and many cases of delayed test termination are now resolved with the explicit context management. I was disappointed to see that end-to-end test runtime from the CLI is not improved on Linux (03:59 min before, 04:10 min after, sample size 1).

Some of these changes modify existing public API, so this commit increments the major/minor digit of the development version.

And fix failing tests on Windows.

This changes all of labkit-ui to eschew usage of the SingletonContext
class in favor of passing the context between components as appropriate,
creating new contexts in relevant situations, and disposing of contexts
when they are finished being used in all cases except for demo code.

It also escapes backslashes of Windows paths hardcoded into macros,
to account for ImageJ macro using backslash as an escape character.

Some of these changes change existing public API, so this commit
increments the major/minor digit of the development version.
@maarzt maarzt self-requested a review October 17, 2024 12:20
Copy link
Collaborator

@maarzt maarzt left a comment

Choose a reason for hiding this comment

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

Thank you for updating the code. Looks good.

.replace('\'', '"')
.replace("INPUT_TIF", inputImage)
.replace("SEGMENTER_FILE", blobsModel)
.replace("OUTPUT_TIF", outputImage.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if using apache-commons StringEscapteUtils.escapeJava(text) would be the even more correct solution here. But I cannot test it, and also wonder why the code replaces double backslashes. Windows would use single backslashes in paths right?

Suggested change
.replace("OUTPUT_TIF", outputImage.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\"));
.replace("OUTPUT_TIF", StringEscapeUtils.escapeJava(outputImage.getAbsolutePath()));

Anyway, this is the test code, not the production code. I'm happy if it runs reliably on Windows, Linux and Mac.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wonder why the code replaces double backslashes.

Yeah, it's tricky. I should have written a comment about it, sorry... I have now pushed a commit that does so. ctrueden/labkit-ui@b82ab70

ctrueden and others added 2 commits October 17, 2024 10:52
And explain why it needs to be so many backslashes. XD
This is probably the correct way to convert a string into a IJM string
literal. I unfortunately couldn't find documentation how IJM escapes
strings.

Using the method is necessary because paths on window use backslashes and
the need to be escaped, the tests fails otherwise.
@maarzt maarzt merged commit 01a5c80 into juglab:master Oct 21, 2024
1 check passed
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 this pull request may close these issues.

2 participants