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

TEST to look at Gh build vs tip #7247

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft

TEST to look at Gh build vs tip #7247

wants to merge 39 commits into from

Conversation

karianna
Copy link
Contributor

No description provided.

@Vest
Copy link
Contributor

Vest commented Dec 24, 2024

Please wait (as usual, I cannot tell until when) and don't merge this PR

Vest added 6 commits December 24, 2024 13:04
…methods that return null. In some cases, the null reference/result was not checked, but the code never failed, because it was not executed.

There were no tests, that is why it was difficult to check, whether the refactoring was right :(
1. Corrected the typo in special properties (light crossbow);
2. Corrected maxdex for MAXDEX bonus;
@karianna
Copy link
Contributor Author

karianna commented Dec 27, 2024

Yeah I assume we won't merge this PR, I figured it was just the easiest way to look at a diff and see if we could spot anything.

# Conflicts:
#	data/pathfinder/paizo/roleplaying_game/core_rulebook/cr_equip_arms_armor.lst
@karianna
Copy link
Contributor Author

karianna commented Jan 7, 2025

Super interesting those tests fail for you but not for me locally!

@Vest
Copy link
Contributor

Vest commented Jan 8, 2025

If you use your version/branch, but not mine, I bet you have this PR: #6975
It comments the most important part, when the character sheet is exported. I have uncommented it, and now the tests started failing. (mostly because LegacyKing corrected some data-files).

@karianna
Copy link
Contributor Author

If you use your version/branch, but not mine, I bet you have this PR: #6975 It comments the most important part, when the character sheet is exported. I have uncommented it, and now the tests started failing. (mostly because LegacyKing corrected some data-files).

OK, so just a data fix required then?

…e the difference between "golden" and generated files).

Trimmed lines in base.xml and base-xml.ftl template.
Corrected pf_Rogue.xml result: +1 reflex comes from Halfling Luch and +3 from his Cloak.
@Vest
Copy link
Contributor

Vest commented Jan 11, 2025

Not only:

  1. DATA changes caused slowtests to fail
  2. Some XML files were not trimmed
  3. The template was trimmed (no leading whitespaces)
  4. That's all. I am waiting for the next build 😄

Vest added 2 commits January 11, 2025 17:34
…actions"

Created a "graceful exit" object + interceptor. It is supposed to replace System.Exit calls in different parts of the project;
Updated reporting.gradle by increasing versions of some dependencies;
Removed a DM_EXIT rule from spotbugs -> the calls of System.Exit must be replaced with GracefulExit.
The decision to create a custom interceptor was taken based on the discussion from Reddit: https://www.reddit.com/r/java/comments/1fpxmfp/jep_486_permanently_disable_the_security_manager/
@Vest
Copy link
Contributor

Vest commented Jan 11, 2025

Two commits above this comment are related to #7079. Security manager is mostly used to intercept System.exit calls;
I have created required classes to replace System.exit with my proposed class.

I hope, you will like it.

@karianna
Copy link
Contributor Author

Looks like it all passed! Shall we take out of Draft?

@Vest
Copy link
Contributor

Vest commented Jan 11, 2025

It is unfinished. Do you insist? I need:

  1. remove security manager
  2. replace all System.exit calls
  3. I have disabled NSIS, but I have not moved to jpackage a windows build yet.

If you don’t need release builds for windows for now. I would implement my PR simply to have indicators that tests are green.

Are you sure? Because I am not.

You can actually merge it, but I only if you plan to work with the new codebase. E.g., continue improving GH actions. If not, I would keep it for a while draft.

@Vest
Copy link
Contributor

Vest commented Jan 13, 2025

The commit 59833c5 addresses the issue #7079. We don't use SecurityManager directly (maybe its exceptions are still thrown here and there), but I have created a custom interceptor, called pcgen.util.ExitInterceptor. It is used in several test-classes.
@karianna, if you want, you can link this PR to the mentioned issue #7079
@Azhrei, I know, you were assigned to this issue. Since I haven't heard any news from you, I think, you were busy with your life. If you are curious about my implementation, can you please review this PR? Not entirely, but you can look at the class: GracefulExit, ExitInterceptor, ExitFunction and few tests that I modified.

I don't know, if I should move my three "exit"-related classes/interfaces into a nested package (just to reduce litter in utils package). If you think, it will be a good idea, I will do this. Something like: "pcgen.util.exit".

Thank you all.

@Vest
Copy link
Contributor

Vest commented Jan 13, 2025

Code coverage of CommandLineArgs Code coverage of GracefulTest

@Azhrei
Copy link
Contributor

Azhrei commented Jan 13, 2025

Thanks. I actually have some time today, so yes, I'll take a look. It'll be a couple hours from now, most likely.

Since intercepting System.exit() is a no-no, I'm very curious to see how you did it!

@Vest
Copy link
Contributor

Vest commented Jan 13, 2025

I don’t intercept it. I have got rid of it. There is only one place, where I allow it - GracefulExit 😄
The rest is filtered out with CheckStyle. If you accidentally write System.exit, it won’t pass CheckStyle (a simple regexp within all sources - dumb, but solid). You can bypass it, if you overcome my regexp (e.g., use reflection + build the string at runtime).
thanks.

@karianna
Copy link
Contributor Author

@Vest Will happily wait until you're done, thanks for tackling this!

Copy link
Contributor

@Azhrei Azhrei left a comment

Choose a reason for hiding this comment

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

Wow, big changeset. 🙂 A lot changes not directly related to GracefulExit, but I mostly skimmed those.

I like the idea of using GE as a front-end on System.exit().

It all looks good to me!

int bonus = (load == Load.MEDIUM) ? 2 : (load == Load.HEAVY) ? 1 : (load == Load.OVERLOAD) ? 0 : statBonus;
int bonus = switch (load)
{
case MEDIUM -> 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be '2' instead of '3'?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch, but no :) I have found this bug, when my integration tests failed:

Encumbrance Effects

Max Dex must be +3

@@ -98,40 +96,35 @@ public static String readFromURI(URI uri) throws PersistenceLayerException
"The file %s uses UTF-8-BOM encoding. LST files must be UTF-8".formatted(uri));
Copy link
Contributor

Choose a reason for hiding this comment

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

Error message should be in a properties file...
Also, at a higher level, a file that starts with a UTF-8-BOM actually is a UTF-8 file, so this whole area might need reworking.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope.
I don't honestly know what to deal with the error here. I have explained you that we had Apache Commons something (maybe String commons, I don't remember exactly) to work with BOM-files. I wanted to optimize the build, and I was trying to get rid of dependencies that are not that important.

When I analyzed all LST files, I found out that we had BOM in (maybe) 10 files, not more. It was easier for me to remove BOM and write code that fails/warns the user, if he gives an unsupported file.

LegacyKing was the first one (we don't have many data-contributors), who stepped this mine first. He was disappointed with the error, and I had to write this code just for him.

My thoughts are to add a Gradle task to go through all LST (or DATA) files and scan for BOM. Either convert them to non-BOM, or fail the build or whatever.

If I don't throw an error, a wrong LST will be pushed to the repo (I don't want this). If I throw an error, probably this build will fail and somebody else will be unhappy. Maybe I should convert LST files silently, but Karianna didn't like when "gradle test" modified .properties files even when nothing was changed. Maybe I'd better write an integration test that will fail, and after this PR is ready we will be able to see in the pull request, who is trying to break the build. Maybe I will also add a task such as "checkLst" to Gradle, so it will convert broken files to good ones. And in the test exception, I will write something like "BOM detected. Test failed. Use gradle checkLst to repair".

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like you've got it under control. I wasn't aware of the backstory. 👍

ShowMessageDelegate.showMessageDialog("Preferences are currently set to NOT allow\nloading of "
+ "sources from web links.\n" + uri + " is a web link", Constants.APPLICATION_NAME,
MessageType.ERROR);
+ "sources from web links.\n" + uri + " is a web link", Constants.APPLICATION_NAME,
Copy link
Contributor

Choose a reason for hiding this comment

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

Another properties file template string...?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done!

Moved a GUI-error message to the localization file.
Formatted error messages
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.

3 participants