Gut
Gut copied to clipboard
Godot 3.5.2 Gut Runner issue with set index 'gut' with value of type 'Control' when running from command line
SPECS:
- Gut version 7.4.1
- Godot version 3.5.2
- Ubuntu 20.04
SITUATION:
- First time using GUT. Ran tests this afternoon following your tutorials for command line. Everything was working fine.
- I setup the proper config file for my project.
- Decided to try out tests of my own project. Started with the following simple test (I only have this and "before_all"/"after_all" which contains a single print statement for test purposes):
func test_set_enemy_speed():
# Setup test
var main_scene = preload("res://scenes/main/Main.tscn")
var main = main_scene.script
var enemy_scene = preload("res://scenes/enemy/EnemyTypeA.tscn")
var original_speed = 5
var new_speed = 10
enemy_scene.original_speed = original_speed
# Modify
main.set_enemy_speed(new_speed, enemy_scene)
# Assert
assert(enemy_scene.speed == new_speed)
PROBLEM:
- The tests don't run and I have the following error:
--- Gut ---
[INFO]: using [/home/<my username>/.local/share/godot/app_userdata/RogueliteFool] for temporary output.
Godot version: 3.5.2
GUT version: 7.4.1
SCRIPT ERROR: Invalid set index 'gut' (on base: 'Reference (test_Main.gd)') with value of type 'Control (gut.gd)'.
at: _setup_script (res://addons/gut/gut.gd:592)
SCRIPT ERROR: Invalid call. Nonexistent function 'before_all' in base 'Reference (test_Main.gd)'.
at: _call_before_all (res://addons/gut/gut.gd:774)
SCRIPT ERROR: Invalid call. Nonexistent function 'after_all' in base 'Reference (test_Main.gd)'.
at: _call_after_all (res://addons/gut/gut.gd:797)
SCRIPT ERROR: Invalid call. Nonexistent function 'get_children' in base 'Reference (test_Main.gd)'.
at: _log_test_children_warning (res://addons/gut/gut.gd:364)
SCRIPT ERROR: Invalid type in function 'remove_child' in base 'Node2D (GutRunner.gd)'. The Object-derived class of argument 1 (Reference (test_Main.gd)) is not a subclass of the expected argument class.
at: _test_the_scripts (res://addons/gut/gut.gd:927)
- I tried removing pre_script and post_script, setting them to empty, setting them to null, etc. (any reference to before_all and after_all), and it gives the error. I tried adding them in, I don't get the error related to them, but I still get the rest of the errors and my tests still don't work.
STEPS TO REPRODUCE:
- Unknown. I'm new to this and I'm unsure what is causing this. Maybe use the following config (generated with the tool/looking at yours in the tutorials) and setup a main scene somewhere?
- I run the tests in the command line on the project root with "godot -s addons/gut/gut_cmdln.gd" { "background_color": "ff262626", "dirs": [ "res://tests" ], "disable_colors": false, "double_strategy": "partial", "font_color": "ffcccccc", "font_name": "CourierPrime", "font_size": 16, "hide_orphans": false, "ignore_pause": false, "include_subdirs": false, "inner_class": "", "junit_xml_file": "", "junit_xml_timestamp": false, "log_level": 1, "opacity": 100, "post_run_script": null, "pre_run_script": null, "prefix": "test_", "selected": "", "should_exit": false, "should_exit_on_success": false, "should_maximize": false, "compact_mode": false, "suffix": ".gd", "gut_on_top": true }
Can you post your entire test_Main.gd
script? I'm not sure what is wrong, but it kinda sounds like your test script isn't extending GutTest
. That shouldn't be possible, as GUT shouldn't include anything that does not extend GutTest
.
Oh boy do I feel stupid now. As I refactored it, I removed the "extends" clause at the top.
Since I made you lose your time, I'll buy your game to thank you for your service and time lol.
To my defence, maybe it could be more explicit that's not able to run gut at all? Like without the extends it shouldn't find the proper objects and methods? Anyway, my bad!
It's an easy mistake, and GUT shouldn't have allowed it. There should be a check. There's a check for Inner-Classes but I couldn't find a check for scripts. I think it got lost in the port to Godot 4. I was expecting GUT to spit out an error stating that the script was ignored because it didn't extend GutTest.
If I can provide anything else to help I'll gladly do it, but between "having no extends at the top" and the config file I posted earlier, pretty much everything on my side is as is. (It now works with extends)
I think we figured it out. GUT should be checking to make sure scripts it thinks are GutTest
scripts are ACTUALLY GutTest
scripts before it goes off treating them like GutTest
scripts.
This has been fixed and will be in the next release.
Fixed in GUT 9 as well.
7.4.2 has been released.