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

Add support for Godot 4.2 #10

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ jobs:
godot_version: 4.1.2
gut_params: -gdir=res://tests/unit
project_path: gut-ci-test-project/godot4

gut-godot42:
name: Run GUT tests for Godot 4
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Godot GUT CI Test
uses: ./
with:
godot_version: 4.2
gut_params: -gdir=res://tests/unit
project_path: gut-ci-test-project/godot4
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:20.04
MAINTAINER "ceceppa" <[email protected]>

# Let the conatiner know that there is no tty
Expand All @@ -10,10 +10,11 @@ RUN apt-get install -y --no-install-recommends \
unzip \
wget \
zip \
libfontconfig-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy the "start" script
COPY init-and-run-tests.sh /init-and-run-tests.sh
RUN chmod 755 /init-and-run-tests.sh

ENTRYPOINT ["/init-and-run-tests.sh"]
ENTRYPOINT ["/init-and-run-tests.sh"]
9 changes: 5 additions & 4 deletions gut-ci-test-project/godot4/.godot/editor/editor_layout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

dock_1_selected_tab_idx=0
dock_2_selected_tab_idx=0
dock_3="Scene,Import"
dock_3_selected_tab_idx=0
dock_4="FileSystem"
dock_4_selected_tab_idx=0
dock_5="Inspector,Node,History"
dock_5_selected_tab_idx=0
dock_6_selected_tab_idx=0
dock_7_selected_tab_idx=0
Expand All @@ -22,15 +19,19 @@ dock_filesystem_split=0
dock_filesystem_display_mode=0
dock_filesystem_file_sort=0
dock_filesystem_file_list_display_mode=1
dock_filesystem_selected_paths=PackedStringArray()
dock_filesystem_selected_paths=PackedStringArray("res://")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://")
dock_3="Scene,Import"
dock_4="FileSystem"
dock_5="Inspector,Node,History"

[EditorNode]

open_scenes=PackedStringArray()
center_split_offset=0
selected_default_debugger_tab_idx=0
selected_main_editor_idx=3
current_scene=""

[ScriptEditor]

Expand Down
223 changes: 112 additions & 111 deletions gut-ci-test-project/godot4/.godot/editor/filesystem_cache8

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ list=Array[Dictionary]([{
"language": &"GDScript",
"path": "res://addons/gut/test.gd"
}, {
"base": &"Node",
"base": &"RefCounted",
"class": &"GutUtils",
"icon": "",
"language": &"GDScript",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="401e77d048b500d714375a77d4ca4326"
dest_md5="4708d41c778709f0d162098764d980d2"
dest_md5="fb76a30be8fc3a37afb8c8f9aa72af1a"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="75a018507317f09d0004b8c1148dd3e5"
dest_md5="89b5af1918246690ea7faaccb02f8ef3"
dest_md5="8b4419b0b844b1380785d9ea60a26db3"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="b3f0e3061651d3bf5c65104a3179e57b"
dest_md5="813c8935f6406a11416b314ebcd424c2"
dest_md5="06aa6ebea73c0f6babf0931f501f3e8a"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="418d6668afcddb7714104f43bfb39657"
dest_md5="3dcc24c9ba895f35991e96ec8fea29a7"
dest_md5="85c0c295c420aff3ee40f5ea57bd70f0"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="696e70ec3151341523d0a1362670d8ad"
dest_md5="944a57e6f0d0739f48f7abf887640214"
dest_md5="1b16c7810c8348dbaa69e8c09dcc20cf"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="15e9706fbc67b38db21e8e963fc1a6c0"
dest_md5="76337b0955fdc2546d19e4afe9463851"
dest_md5="3b122e855d11dacfb3d00e4b6e16bf34"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="ace04e0c254883041bc7effb9d951cf2"
dest_md5="99808d59ab309bfdfb13f2b1f153f1ab"
dest_md5="af668be9c769c0210666d312c070d751"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="03ef685b34f3356631c3f60c91917002"
dest_md5="f7305a5226f42aaf22fbbfdb954da0bb"
dest_md5="5c06801e6d64aee6781d0fc018c5825b"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="a39e5778312a715a82d7afe88ebac015"
dest_md5="ae3d566230ff986090ca2b06c5cd1e4c"
dest_md5="be48af0830ecc47584cbf301e770141a"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="9f56fb2bffbac7662cb53b783248698a"
dest_md5="462377e7a8c4f282ecd5c29677eb7ccc"
dest_md5="07a930b5a5d649a82260702ccfbd11ea"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="40a68e931d9f1c543eac616acb53b2d8"
dest_md5="9e0c62a91996c0bb378887eb53caa407"
dest_md5="3ff5a70e14b4eb15b942e4d79831c755"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="fb8c29136b1ee99fe9dd45a6f8bcc9fd"
dest_md5="7c7c5b9b79c24188b971f64283dfa41d"
dest_md5="304024f8690d4b17be3efd60949355ac"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="6f7a0200c4c8d72d3a94d011d1934fbb"
dest_md5="d947a28da7ac1678512f7e261666161c"
dest_md5="98eb516765a2e2f3f490c1f4ab9fe7e0"

Binary file modified gut-ci-test-project/godot4/.godot/uid_cache.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions gut-ci-test-project/godot4/addons/gut/awaiter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func _physics_process(delta):


func _end_wait():
if(_signal_to_wait_on != null and _signal_to_wait_on.is_connected(_signal_callback)):
_signal_to_wait_on.disconnect(_signal_callback)

_wait_time = 0.0
_wait_frames = 0
_signal_to_wait_on = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{func_decleration}
__gutdbl.spy_on('{method_name}', {param_array})
{vararg_warning}__gutdbl.spy_on('{method_name}', {param_array})
if(__gutdbl.should_call_super('{method_name}', {param_array})):
return {super_call}
else:
return __gutdbl.get_stubbed_return('{method_name}', {param_array})

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var __gutdbl_values = {
gut = {gut_id},
from_singleton = '{singleton_name}',
is_partial = {is_partial},
doubled_methods = {doubled_methods},
}
var __gutdbl = load('res://addons/gut/double_tools.gd').new(__gutdbl_values)

Expand Down
37 changes: 25 additions & 12 deletions gut-ci-test-project/godot4/addons/gut/double_tools.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,58 @@ var is_partial = null
var double = null

const NO_DEFAULT_VALUE = '!__gut__no__default__value__!'
func _init(values=null):
if(values != null):
double = values.double
thepath = values.thepath
subpath = values.subpath
stubber = from_id(values.stubber)
spy = from_id(values.spy)
gut = from_id(values.gut)
from_singleton = values.from_singleton
is_partial = values.is_partial

if(gut != null):
gut.get_autofree().add_free(double)


func from_id(inst_id):
if(inst_id == -1):
return null
else:
return instance_from_id(inst_id)


func should_call_super(method_name, called_with):
if(stubber != null):
return stubber.should_call_super(double, method_name, called_with)
else:
return false


func spy_on(method_name, called_with):
if(spy != null):
spy.add_call(double, method_name, called_with)


func get_stubbed_return(method_name, called_with):
if(stubber != null):
return stubber.get_return(double, method_name, called_with)
else:
return null


func default_val(method_name, p_index, default_val=NO_DEFAULT_VALUE):
if(stubber != null):
return stubber.get_default_value(double, method_name, p_index)
else:
return null

func _init(values=null):
if(values != null):
double = values.double
thepath = values.thepath
subpath = values.subpath
stubber = from_id(values.stubber)
spy = from_id(values.spy)
gut = from_id(values.gut)
from_singleton = values.from_singleton
is_partial = values.is_partial

func vararg_warning():
if(gut != null):
gut.get_autofree().add_free(double)

gut.get_logger().warn(
"This method contains a vararg argument and the paramter count was not stubbed. " + \
"GUT adds extra parameters to this method which should fill most needs. " + \
"It is recommended that you stub param_count for this object's class to ensure " + \
"that there are not any parameter count mismatch errors.")
37 changes: 21 additions & 16 deletions gut-ci-test-project/godot4/addons/gut/doubler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ func _get_indented_line(indents, text):


func _stub_to_call_super(parsed, method_name):
if(_utils.non_super_methods.has(method_name)):
if(!parsed.get_method(method_name).is_eligible_for_doubling()):
return

var params = _utils.StubParams.new(parsed.script_path, method_name, parsed.subpath)
params.to_call_super()
_stubber.add_stub(params)


func _get_base_script_text(parsed, override_path, partial):
func _get_base_script_text(parsed, override_path, partial, included_methods):
var path = parsed.script_path
if(override_path != null):
path = override_path
Expand Down Expand Up @@ -170,14 +170,15 @@ func _get_base_script_text(parsed, override_path, partial):
"gut_id":gut_id,
"singleton_name":'',#GutUtils.nvl(obj_info.get_singleton_name(), ''),
"is_partial":partial,
"doubled_methods":included_methods,
}

return _base_script_text.format(values)


func _is_valid_double_method(parsed_script, parsed_method):
func _is_method_eligible_for_doubling(parsed_script, parsed_method):
return !parsed_method.is_accessor() and \
!parsed_method.is_black_listed() and \
parsed_method.is_eligible_for_doubling() and \
!_ignored_methods.has(parsed_script.resource, parsed_method.meta.name)


Expand All @@ -197,30 +198,34 @@ func _create_script_no_warnings(src):


func _create_double(parsed, strategy, override_path, partial):
var base_script = _get_base_script_text(parsed, override_path, partial)
var super_name = ""
var path = ""

path = parsed.script_path
var dbl_src = ""
dbl_src += base_script
var included_methods = []

for method in parsed.get_local_methods():
if(_is_valid_double_method(parsed, method)):
if(_is_method_eligible_for_doubling(parsed, method)):
included_methods.append(method.meta.name)
var mthd = parsed.get_local_method(method.meta.name)
if(parsed.is_native):
dbl_src += _get_func_text(method.meta, parsed.resource, super_name)
dbl_src += _get_func_text(method.meta, parsed.resource)
else:
dbl_src += _get_func_text(method.meta, path, super_name)
dbl_src += _get_func_text(method.meta, path)

if(strategy == _utils.DOUBLE_STRATEGY.INCLUDE_NATIVE):
for method in parsed.get_super_methods():
if(_is_valid_double_method(parsed, method)):
if(_is_method_eligible_for_doubling(parsed, method)):
included_methods.append(method.meta.name)
_stub_to_call_super(parsed, method.meta.name)
if(parsed.is_native):
dbl_src += _get_func_text(method.meta, parsed.resource, super_name)
dbl_src += _get_func_text(method.meta, parsed.resource)
else:
dbl_src += _get_func_text(method.meta, path, super_name)
dbl_src += _get_func_text(method.meta, path)

var base_script = _get_base_script_text(parsed, override_path, partial, included_methods)
dbl_src = base_script + "\n\n" + dbl_src


if(print_source):
print(_utils.add_line_numbers(dbl_src))
Expand All @@ -234,7 +239,7 @@ func _create_double(parsed, strategy, override_path, partial):

func _stub_method_default_values(which, parsed, strategy):
for method in parsed.get_local_methods():
if(!method.is_black_listed() && !_ignored_methods.has(parsed.resource, method.meta.name)):
if(method.is_eligible_for_doubling() && !_ignored_methods.has(parsed.resource, method.meta.name)):
_stubber.stub_defaults_from_meta(parsed.script_path, method.meta)


Expand Down Expand Up @@ -262,12 +267,12 @@ func _get_inst_id_ref_str(inst):
return ref_str


func _get_func_text(method_hash, path, super_=""):
func _get_func_text(method_hash, path):
var override_count = null;
if(_stubber != null):
override_count = _stubber.get_parameter_count(path, method_hash.name)

var text = _method_maker.get_function_text(method_hash, path, override_count, super_) + "\n"
var text = _method_maker.get_function_text(method_hash, override_count) + "\n"

return text

Expand Down
14 changes: 4 additions & 10 deletions gut-ci-test-project/godot4/addons/gut/gui/GutSceneTheme.tres

Large diffs are not rendered by default.

Loading
Loading