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

Implement Godot-in-the-loop test suite and fix debugger errors #788

Merged
merged 42 commits into from
Feb 10, 2025

Conversation

MichaelXt
Copy link
Contributor

@MichaelXt MichaelXt commented Feb 4, 2025

Fixes for get variables issues

  1. Same reference but different variable override fix, which resulted in variables being lost
    ** Now different GodotVariable instances are used for different variables with same reference
    ** const replacement = {value: rawObject, sub_values: sub_values } as GodotVariable;
  2. 'Signal' type handling crash and string representation fix
    ** value.sub_values()?.map
  3. Empty scopes return fix
    ** if (this.ongoing_inspections.length === 0 && stackVars.remaining == 0)
  4. Various splice from findIndex fixes (where findIndex can return -1)
  5. Added variables tests
    ** updated vscode types to version 1.96 to use onDidChangeActiveStackItem for breakpoint hit detection in tests
    1 & 3 should fix Race condition in godot4\debug_session::get_variable() results in adding watch and showing variables stops working. #779

Fixes the VSCode watch window freeze due to missing response in case of exception. See related godotengine#779
1. Same reference but different variable override fix, which resulted in variables being lost
** Now different GodotVariable instances are used for different variables with same reference
** const replacement = {value: rawObject, sub_values: sub_values } as GodotVariable;
2. 'Signal' type handling crash and string representation fix
** value.sub_values()?.map
3. Empty scopes return fix
** if (this.ongoing_inspections.length === 0  && stackVars.remaining == 0)
* Various splice from findIndex fixes (where findIndex can return -1)
* updated vscode types to version 1.96 to use `onDidChangeActiveStackItem` for breakpoint hit detection in tests
1 & 3 should fix godotengine#779
@MichaelXt MichaelXt changed the title Mikp/variables crash fixes Variables crash fixes Feb 4, 2025
@MichaelXt MichaelXt changed the title Variables crash fixes Variables crashes fixes Feb 4, 2025
@DaelonSuzuka DaelonSuzuka self-requested a review February 4, 2025 15:17
@DaelonSuzuka DaelonSuzuka self-assigned this Feb 4, 2025
@MichaelXt
Copy link
Contributor Author

Looks like godot is not installed or not aliased on the test machines. I can disable the tests requiring godot to unblock the pipeline. This way at least local testing will still be possible.

@DaelonSuzuka
Copy link
Collaborator

Yeah, until now there haven't been any tests that involved godot. You could figure out how to set that up, wink wink.

@DaelonSuzuka
Copy link
Collaborator

At a glance this looks fantastic, thank you for the work setting this up!

I'm going to try and dig into this later today.

@MichaelXt
Copy link
Contributor Author

MichaelXt commented Feb 6, 2025

This PR is ready.
Regarding tests: The DAP implementation is flaky, hence there are bunch of async sleeps in tests to workaround current DAP limitations.
There are several more issues discovered related to variables and watch window, which need to be addressed in a separate PR.

@Calinou Calinou added the bug label Feb 7, 2025
@MichaelXt
Copy link
Contributor Author

@DaelonSuzuka, I've re-wrote the variables code to make it more reliable and closer mapped to DAP and godot concepts. Would you like to review it as a separate PR or part of this PR?

@DaelonSuzuka
Copy link
Collaborator

Hey @MichaelXt, sorry this has taken me so long to review. My productive hours have nosedived lately and I'm not sure why.

I just got your tests to run locally, so that looks good to me.

I have two minor complaints:

When I first did npm test I got this:

'"godot"' is not recognized as an internal or external command,
operable program or batch file.
'"p:\_godot\godot-vscode-plugin\test_projects\test-dap-project-godot4\godot"' is not recognized as an internal or external command,
operable program or batch file.

My Godot 4 binary was named godot4.exe, and that's what editorPath.godot4 in my extension settings is set to. Can you make the test check that I don't have a godot.exe on my path and explicitly fail? (eventually I hope we can expand this test suite to run against multiple godot binaries, so it's fine to expect a specific naming convention, but silently passing isn't okay)

Then, once I made godot.exe binary, that error went away but there was no additional output in the test terminal. I managed to fix that by running godot --import test_projects/test-dap-project-godot4/project.godot --headless, which I grabbed from ci.yml, and after I did the initial import the tests ran and all passed.

Can you make sure this is also a failing condition?

Thanks again for the contribution, this is a huge upgrade!

@MichaelXt
Copy link
Contributor Author

MichaelXt commented Feb 10, 2025

@DaelonSuzuka, thanks for taking a look and reviewing!
The test code is not setting any workspace settings, including it doesn't set the godotTools.editorPath.godot4, hence the vscode-test uses following: Global settings, User Settings, Workspace Settings in order to find the godotTools.editorPath.godot4 executable path, default plugin settings.
Those are the current defaults for the plugin:

//file: package.json
		"godotTools.editorPath.godot3": {
			"type": "string",
			"default": "godot3",
			"description": "Path to the Godot 3 editor executable"
		},
		"godotTools.editorPath.godot4": {
			"type": "string",
			"default": "godot",
			"description": "Path to the Godot 4 editor executable"
		},

I don't think we should hardcode the test to use godot4 executable, ignoring all the settings. But if you think that we should add the .vscode/settings.json with hardcoded value to godot4 we could do that. lmk.

Working on executing ${godotTools.editorPath.godot4} --import --headless now.

@DaelonSuzuka
Copy link
Collaborator

I don't think we should hardcode the test to use godot4 executable, ignoring all the settings. But if you think that we should add the .vscode/settings.json with hardcoded value to godot4 we could do that. lmk.

Can you make the test runner set godotTools.editorPath.godotX? In the future I want to be able to run tests against, say, Godot 4.3 and 4.4, to test before and after a breaking change.

The most important thing is just making sure it actually fails if the binary is missing, though.

@DaelonSuzuka
Copy link
Collaborator

@MichaelXt If it's problematic to run the import command every time, you can just have it check if the import has happened, and have an error telling the user to run npm run import-test-projects or something

@MichaelXt
Copy link
Contributor Author

set godotTools.editorPath.godotX

Could you please elaborate a bit. do you suggest to call:

const config = vscode.workspace.getConfiguration("godotTools");
config.update("editorPath.godot4", "godot4", vscode.ConfigurationTarget.Workspace);

on suiteSetup? That effectively is the same as adding test_projects/test-dap-project-godot4/.vscode/settings.json with

{
  "godotTools.editorPath.godot4": "godot4"
}

@DaelonSuzuka
Copy link
Collaborator

DaelonSuzuka commented Feb 10, 2025

Well I'm still not very familiar with the test runner, so I was trying not to speak out of my depth about the implementation.

I think the first one is what I was describing. The purpose would be to run the same test project using two different Godot versions, so I believe I'd want to set the value of editorPath.godot4 from the js test code, before launching the test environment.

Am I better off making additional test projects? test_projects/test-debug-protocol-godot4.1, test_projects/test-debug-protocol-godot4.2, etc? That would avoid potential issues with re-importing between different version....

This probably isn't worth your time right now, so if you just make sure the test fails if the binary is missing (for whatever reason) then we can call this PR done.

@MichaelXt
Copy link
Contributor Author

Agree, it is better to have separate project per godot version:

  1. The common godot folder is not cross-version compatible
  2. The new functionality will require new code in the godot project

Yes, with the addition of godot --import, the project will fail if godot executable is not found (as defined by config).

@DaelonSuzuka
Copy link
Collaborator

Thanks for indulging my rambling; this looks good to me.

@DaelonSuzuka DaelonSuzuka changed the title Variables crashes fixes Implement Godot-in-the-loop test suite and fix debugger errors Feb 10, 2025
@DaelonSuzuka DaelonSuzuka merged commit 2490d0c into godotengine:master Feb 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants