Gut icon indicating copy to clipboard operation
Gut copied to clipboard

Setting project setting debug/gdscript/warnings/untyped_declaration to "error" prevents GUT from running tests.

Open PerMalmberg opened this issue 2 years ago • 11 comments

Hi,

Not familiar enough with GUT yet to make a PR to fix this, so here's an issue instead.

If you set the project setting debug/gdscript/warnings/untyped_declaration then run tests via GUT, it prevents tests from running and outputs the following on the debugger tab:

image

Switching to Warning, results in this warning, but at least GUT still works:

image

PerMalmberg avatar Jan 08 '24 19:01 PerMalmberg

Hey @PerMalmberg I'm not the maintainer, but since I just learned from you that this option exists (thank you!), I looked into it.

I went down a whole rabbit hole as this piece of code in stubber.gd is super interesting, but as I was testing it seems to me that Gut isn't written with required typing in mind. There are several places where there is no static typing (such as __gutdbl_values). Enabling your use case would require going through the entire Gut codebase and fixing up the types.

In essence, it seems to me that in the short term you are stuck running with the warning option instead of setting it to error. Alternatively, you could run Gut from the command line and point it to an alternative Godot.project file which does not include this option, or turning this option off when you want to run Gut.

That being said, I'd wait what the maintainers say as I'm not actively developing Gut either.

janosdebugs avatar Jan 08 '24 21:01 janosdebugs

Hm, considering it only gives warnings at two places, I was hoping it would only be there it needed fixing. Maybe more things are revealed when using more things of GUT, I have a very basic test at the moment.

PerMalmberg avatar Jan 08 '24 22:01 PerMalmberg

I found a few places where there were no type annotations. Your sample project may be worth posting though, it may serve as a good starting point for tracking these down. The Gut test cases themselves don't have type annotations in a number of places, so opening the Gut project with this setting enabled will also not work.

janosdebugs avatar Jan 08 '24 22:01 janosdebugs

This has been fixed but I don't think it's been released (#533). The code is dynamically generated so it doesn't get associated with the addon and therefore is not ignored.

GUT was started back in the 2.x days, and static typing wasn't a thing. I also quite enjoy not caring about datatypes 99% of the time. It should still run though if you have settings that "ignore addons" doesn't cover.

bitwes avatar Jan 09 '24 01:01 bitwes

Hm, I was sure I got it from the main branch. Will double check tonight.

PerMalmberg avatar Jan 09 '24 07:01 PerMalmberg

Hey @bitwes thanks for the answer! I found other similar issues while digging into this. Should I be reporting them then?

janosdebugs avatar Jan 09 '24 07:01 janosdebugs

@janosdebugs if they can cause errors, yes, you can add them here.

bitwes avatar Jan 09 '24 15:01 bitwes

Turns out I downloaded 9.1.1, not the master branch.

PerMalmberg avatar Jan 09 '24 18:01 PerMalmberg

@bitwes to clarify: I'm developing an addon and I'm running into issues like this:

 Debugger Break, Reason: 'Parser Error: Variable "Optparse" has no static type. (Warning treated as error.)'
*Frame 0 - res://addons/gut/gut_cmdln.gd:15 in function ''

Do you still want these reported or is the code in the addons/gut folder out of scope for full static typing? There are 1000+ of them.

janosdebugs avatar Jan 09 '24 21:01 janosdebugs

Ahh, I would consider those out of scope. I don't expect to move to static typing.

If this is preventing you from being able to use GUT, then finding a way to prevent that would be something I would definitely consider. Are there any issues with ignoring addons and being able to still get warnings for your own addon code?

bitwes avatar Jan 10 '24 00:01 bitwes

Since I'm developing an addon myself, I'd need to move the code out of the addons folder if I wanted to use an error level for these issues. Currently, I'm not able to check for static typing using CI since I have set these to warn only for now. I think this shouldn't be a GUT issue, it should be a Godot issue to be able to set linting rules in a more granular fashion. I'll work around it and potentially submit a patch to Godot.

Again, thank you for your work @bitwes, I don't think you should have to deal with my preference for static typing. Unless there's a large demand for this, please ignore this use case, I can work around it.

janosdebugs avatar Jan 10 '24 09:01 janosdebugs

@bitwes Is there a plan to make a new release that contains #533 ? Considering the increased popularity of typed GDScript and that GUT is the go-to testing framework for Godot, I think it would be good make it part of an official release sooner rather than later.

With that said, I just want to add my sincere thanks for making GUT.

PerMalmberg avatar Jan 13 '24 11:01 PerMalmberg

Fixed in 9.2 which has been released.

bitwes avatar Feb 08 '24 00:02 bitwes