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

Document use of --no-window option for command line and vscode plugin #360

Open
bitwes opened this issue May 9, 2022 · 3 comments
Open

Comments

@bitwes
Copy link
Owner

bitwes commented May 9, 2022

Per #357, you can use the --no-window Godot command line option to hide the Godot window when running tests. You can also add this option to the "Additional Options" in the VSCode GUT Extension. This should be documented somewhere so it's easier to find by others. There are also some considerations to make when using it.

  • The "should exit" option should be specified, otherwise you have to break out at the end of the run. If the option is detectable then GUT should take appropriate action and exit.
  • Calls to pause_before_teardown will cause the tests to hang since you won't be able to see the screen to click "continue". Again, if the option is detectable GUT can take the right action here.
  • You should specify the "ignore pause" option per the previous point.
  • You of course cannot watch your tests run.
@bitwes
Copy link
Owner Author

bitwes commented May 20, 2022

I could not find a way to auto-detect that Godot is running in headless or "no window" mode. An option should be added that will override settings and take other actions to make running without a window more user friendly.

  • should_exit = true
  • should_exit_on_success = false
  • ignore_pauses = true
  • disable GUI printer (saves some cycles)

@bitwes bitwes added this to the 7.4.0 milestone May 20, 2022
@russmatney
Copy link

Thanks much for GUT - it's been a good experience to start working with it today!

Apologies for the large comment here - I was hoping to turn this into a PR, but couldn't find a way to make it work, so here's my notes instead.

I was curious about enabling --no-window from the GUT panel, to prevent an extra window from opening when running tests through the editor, but once I found this issue, I thought I'd dig in. I'm pretty new to digging into godot internals, so take all this with a grain of salt!

One thing is that --no-window has been removed in favor of --headless in this commit: godotengine/godot@09386ba So that command line option shift at some point (maybe in 3.5?).

It looks like DisplayServer - window_can_draw will soon be a preferred way to check for this (internally in godot, anyway): godotengine/godot@39efccf In the meantime: OS::get_singleton()->can_draw() && !OS::get_singleton()->is_no_window_mode_enabled() seems to be the 3.x compatible version (godotengine/godot#50767 (comment)).

I couldn't find anything like this available in gdscript, expect for OS.can_draw(), which unfortunately seems to return true regardless of --no-window.

I thought maybe OS.get_cmdline_args() would include --no-window, but it seems to be cleared/removed before the shell script runs, so it doesn't show up in that array.

The Godot OS class itself does not expose anything directly helpful, despite the OS singleton in godot's source maintaining a _no_window bool - perhaps this has just never been requested, so it's not exposed? Or maybe there's some idea that people will use the "headless" godot builds directly for cases like this?

I tried a few different things in a script:

#!/usr/bin/env -S godot -s --no-window
extends SceneTree


func _init():
	print("os can draw: ", OS.can_draw())
	print("os props: ", OS.get_property_list())

	# for p in OS.get_property_list():
	# 	print(p.name)
	# 	print("  " + p.name + ": ", OS.get(p.name))

	print("window position: ", OS.get_window_position())
	print("no window: ", OS.get_window_position() == Vector2.ZERO)
	# print("minimized: ", OS.window_minimized)
	quit()

One hacky option is something like: OS.get_window_position() == Vector2.ZERO, which isn't perfect but might be right in most cases? Not the best solution, there might be weird cases that break it (some strange window managers? windows?). If you don't mind using the window_position like this, I can take a shot at a PR that fixes the non-interactive options you listed.

It seems there's no way to opt-in to --no-window behavior from gdscript, at least not without a PR to godot itself that exposes more of the OS singleton. If there are workarounds for doing this, I'm very interested! I'm trying to get a better grasp of gdscript + godot in general, especially for more command-line tools like this.

@bitwes bitwes removed this from the 7.4.0 milestone Aug 13, 2022
@theludovyc
Copy link
Contributor

theludovyc commented Jan 4, 2023

You can also add this option to the "Additional Options" in the VSCode GUT Extension. This should be documented somewhere so it's easier to find by others. There are also some considerations to make when using it.

Do you want to talk about it there https://github.com/bitwes/gut-extension#gut-extensionadditionaloptions in Possible Uses ?

Like

  • add --no-window to hide the Godot window when running tests

I tested it, it works :) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants