Skip to content

Add unit tests for user scripts module#628

Merged
WhiteMagic merged 3 commits into
WhiteMagic:developfrom
code-monet:user_script_unit_test
Sep 8, 2025
Merged

Add unit tests for user scripts module#628
WhiteMagic merged 3 commits into
WhiteMagic:developfrom
code-monet:user_script_unit_test

Conversation

@code-monet

@code-monet code-monet commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

One thing I noticed is that the virtual input variable seems to be incomplete - in the GUI you can only pick axes, not buttons or hats?

For the next couple of pull requests the plan is to add:

  1. An end-to-end integration test using a vJoy device.
  2. An integration test using logical devices, if these are available in user scripts (or the idea is to eventually have them available there?)

@WhiteMagic

Copy link
Copy Markdown
Owner

If you can't pick other input types and one should be able to, then yeah, that's definitely not intended. Though one can define what kind of inputs should be allowed, I'll have to look at how complete/buggy that is.

You may definitely run into bugs with the user scripts part as that's not been heavily tested and refactored quite heavily. So if you see something that's weird just let me know. The logical devices will definitely be part of the user scripts part as well but obviously right now aren't there yet. I should put that on the list of things to add.

Comment thread test/unit/conftest.py
# Data below was generated from a vJoy device.
guid = dill._GUID(
def get_fake_device_guid(is_virtual: bool) -> uuid.UUID:
return dill._GUID(

@WhiteMagic WhiteMagic Sep 3, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Beware that while both dill.GUID and uuid.UUID are the same thing (as far as the values they can hold internally), their types aren't interchangeable, and it can cause tricky bugs if they're mixed. I try hard to have only uuid.UUID inside of Gremlin with dill.GUID propagating no further than the events Gremlin receives from the dill library. Though there are likely still places where dill.GUID are floating around.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! The type hint was wrong, fixed.

@code-monet
code-monet force-pushed the user_script_unit_test branch from 3caf2f3 to ec5533a Compare September 4, 2025 05:35
@code-monet

Copy link
Copy Markdown
Contributor Author

If you can't pick other input types and one should be able to

Ah, this was key. So it's user error in my part, I forgot that in my script I had specified it to be specifically an axis.


Okay, added coverage for the input variables for each type. Let me know if any more changes are needed.

@WhiteMagic

Copy link
Copy Markdown
Owner

Looks good to me 👍

@WhiteMagic
WhiteMagic merged commit 0bc1a63 into WhiteMagic:develop Sep 8, 2025
1 check passed
@code-monet
code-monet deleted the user_script_unit_test branch September 9, 2025 03:32
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