Multitool - An implementation and feature discussion.

Thank you again. I do not multi-task well and am focused on writing a document for real life and a KoLmafia test but this is next on the list.
 
New version. I now attempt to ignore local files that don't match the expected name convention which is ToolName-version-M.jar or ToolName-version.jar. I need to look at your failure to launch report. Any chance the multitool log file has something? I may also have incorrectly detected how to run Java on your system. Thanks.
 
Yep, that's exactly the problem.


This is essentially backsliding from attempting to solve https://kolmafia.us/threads/multito...d-feature-discussion.30272/page-2#post-176348 -- you really should look into setting up tests.
*snicker*

I'm fundamentally lazy, don't multi-task well and this never stays at the top of my queue for very long. Working on it is also a reminder of how far my skills and knowledge are from the current state of the art ;-)

I'd love tests. I had not done them yet because I'm not sure I am prepared to relearn what little I knew about mocking and not sure what other techniques would actually be beneficial for code that does most of its work querying the OS, file system and external web sites. That said, there is something to be looked since the code finds java at C:/Program\ Files/Java/jdk-21/bin/java but Cygwin finds it at c/Program Files/Common Files/Oracle/Java/javapath/java so there are some tests that would be helpful.

I am also dragging my feet on test because there are some implementation details that almost certainly won't survive scrutiny. I have a class that I think could be a Record and my avoidance of regex and JSON parsing is painfully obvious. So do put the effort into tests before or after code changes to resolve those? The right answer is before but note "fundamentally lazy" ;-)

But thank you for comments that will eventually move me in the right direction.
 
a class that I think could be a Record
Observation before you go too far down that path: Record didn't come until what, Java 15? (okay, looks like first preview was Java 14 and it was finalized in 16.)

So do put the effort into tests before or after code changes to resolve those? The right answer is before but note "fundamentally lazy" ;-)
You're correct that the right answer is generally "before refactoring" to prevent further backsliding :)

Regarding the reported failure mode, I suspect the simplest fix is to use Runtime.exec(String[]) so Java doesn't need to tokenize your string for you.
 
Observation before you go too far down that path: Record didn't come until what, Java 15? (okay, looks like first preview was Java 14 and it was finalized in 16.)


You're correct that the right answer is generally "before refactoring" to prevent further backsliding :)

Regarding the reported failure mode, I suspect the simplest fix is to use Runtime.exec(String[]) so Java doesn't need to tokenize your string for you.

I didn't use a record because I was too lazy (there's that word again) to see when they were introduced but not using one was easier than looking it up.

Just FYI it isn't logging anything either and with the run parameter and failure it never runs mafia

I just got a KoLmafia test working so am resting on my laurels momentarily. multitool is not especially robust in the sense of detecting and working around errors. It really depends on the naming convention so fixing the NPE could have broken something downstream. I have things to chew on. As it stands if the only KoLmafia jar files is "misnamed" then I would expect it to download latest mafia and multitool jars but launch nothing. But if you rerun multitool I would expect it to launch the mafia jar that was just downloaded because it would be named properly. I need to dig deeper. I may have to decide to allow "Latest" to, by definition, be newer than any numbered version or just delete delete everything in the directory that does not fit the pattern.

As currently implemented the log file name is based on date and the file is overwritten, not appended to, so you probably need to look at the file to see if anything is going on and I probably need to timestamp entries and perhaps Append.
 
As it stands if the only KoLmafia jar files is "misnamed" then I would expect it to download latest mafia and multitool jars but launch nothing. But if you rerun multitool I would expect it to launch the mafia jar that was just downloaded because it would be named properly.
I am surprised by the notion that multitool might download a new jar, and then not launch it. Would it launch the old jar? Would it do nothing?

IMO the "expected" behavior from what I am viewing as a launcher + auto-updater is the following steps:
  1. Update Mafia if necessary.
  2. Clean up old versions.
  3. Launch the latest jar.
just delete delete everything in the directory that does not fit the pattern
Please don't do this -- you will get many angry comments from people complaining that you nuked their Downloads folder or worse.

As currently implemented the log file name is based on date and the file is overwritten, not appended to, so you probably need to look at the file to see if anything is going on and I probably need to timestamp entries and perhaps Append.
There are pros and cons. I personally opt to clobber my logfile because I don't really care about execution history across days, and I like not having to worry about cleaning up the log file periodically.
 
Back
Top