mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-06-29 18:55:31 +02:00
added windows pty support
This commit is contained in:
parent
77ae56f72d
commit
bd399e5603
23 changed files with 1478 additions and 695 deletions
|
@ -10,6 +10,7 @@ func before_each():
|
|||
|
||||
|
||||
func test_bell() -> void:
|
||||
watch_signals(terminal)
|
||||
terminal.bell_cooldown = 0
|
||||
terminal.write(char(7))
|
||||
terminal.write(char(0x07))
|
||||
|
@ -42,8 +43,8 @@ class TestTheme:
|
|||
|
||||
const TestScene := preload("../scenes/theme.tscn")
|
||||
|
||||
const default_theme := preload("res://addons/godot_xterm/themes/default.tres")
|
||||
const alt_theme := preload("res://addons/godot_xterm/themes/default_light.tres")
|
||||
const default_theme := preload("res://addons/godot_xterm/themes/default_green.tres")
|
||||
const alt_theme := preload("res://addons/godot_xterm/themes/default_white.tres")
|
||||
|
||||
const COLORS := [
|
||||
"ansi_0_color",
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const EMPTY_VAR = "GODOT_XTERM_TEST_EMPTY_ENV_VAR"
|
||||
const TEST_VAR = "GODOT_XTERM_TEST_ENV_VAR"
|
||||
const TEST_VAL = "TEST123"
|
||||
|
||||
var env: Dictionary
|
||||
|
||||
|
||||
func before_each():
|
||||
OS.set_environment(EMPTY_VAR, "")
|
||||
OS.set_environment(TEST_VAR, TEST_VAL)
|
||||
env = LibuvUtils.get_os_environ()
|
||||
|
||||
|
||||
func test_has_empty_var():
|
||||
assert_has(env, EMPTY_VAR)
|
||||
|
||||
|
||||
func test_empty_var_has_empty_val():
|
||||
assert_eq(env[EMPTY_VAR], "")
|
||||
|
||||
|
||||
func test_has_test_var():
|
||||
assert_has(env, TEST_VAR)
|
||||
|
||||
|
||||
func test_test_var_has_correct_val():
|
||||
assert_eq(env[TEST_VAR], TEST_VAL)
|
|
@ -96,7 +96,7 @@ func test_emits_exit_code_on_failure():
|
|||
func test_emits_exited_on_kill():
|
||||
subject.call("fork", "yes")
|
||||
await wait_frames(1)
|
||||
subject.call_deferred("kill", PTY.SIGNAL_SIGKILL)
|
||||
subject.call_deferred("kill", PTY.IPCSIGNAL_SIGKILL)
|
||||
await wait_for_signal(subject.exited, 1)
|
||||
assert_signal_emitted(subject, "exited")
|
||||
|
||||
|
@ -104,9 +104,9 @@ func test_emits_exited_on_kill():
|
|||
func test_emits_exited_with_signal():
|
||||
subject.call("fork", "yes")
|
||||
await wait_frames(1)
|
||||
subject.call_deferred("kill", PTY.SIGNAL_SIGSEGV)
|
||||
subject.call_deferred("kill", PTY.IPCSIGNAL_SIGSEGV)
|
||||
await wait_for_signal(subject.exited, 1)
|
||||
assert_signal_emitted_with_parameters(subject, "exited", [0, PTY.SIGNAL_SIGSEGV])
|
||||
assert_signal_emitted_with_parameters(subject, "exited", [0, PTY.IPCSIGNAL_SIGSEGV])
|
||||
|
||||
|
||||
# Run the same tests, but with use_threads = false.
|
||||
|
@ -189,7 +189,7 @@ class TestPTYSize:
|
|||
await wait_for_signal(subject.data_received, 1)
|
||||
|
||||
func after_each():
|
||||
subject.call_deferred("kill", PTY.SIGNAL_SIGHUP)
|
||||
subject.call_deferred("kill", PTY.IPCSIGNAL_SIGHUP)
|
||||
await wait_for_signal(subject.exited, 1)
|
||||
|
||||
func test_pty_default_size():
|
||||
|
|
|
@ -64,18 +64,18 @@ class TestInterface:
|
|||
# Enums.
|
||||
|
||||
func test_has_enum_signal():
|
||||
assert_eq(described_class.SIGNAL_SIGHUP, 1)
|
||||
assert_eq(described_class.SIGNAL_SIGINT, 2)
|
||||
assert_eq(described_class.SIGNAL_SIGQUIT, 3)
|
||||
assert_eq(described_class.SIGNAL_SIGILL, 4)
|
||||
assert_eq(described_class.SIGNAL_SIGTRAP, 5)
|
||||
assert_eq(described_class.SIGNAL_SIGABRT, 6)
|
||||
assert_eq(described_class.SIGNAL_SIGFPE, 8)
|
||||
assert_eq(described_class.SIGNAL_SIGKILL, 9)
|
||||
assert_eq(described_class.SIGNAL_SIGSEGV, 11)
|
||||
assert_eq(described_class.SIGNAL_SIGPIPE, 13)
|
||||
assert_eq(described_class.SIGNAL_SIGALRM, 14)
|
||||
assert_eq(described_class.SIGNAL_SIGTERM, 15)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGHUP, 1)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGINT, 2)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGQUIT, 3)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGILL, 4)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGTRAP, 5)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGABRT, 6)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGFPE, 8)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGKILL, 9)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGSEGV, 11)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGPIPE, 13)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGALRM, 14)
|
||||
assert_eq(described_class.IPCSIGNAL_SIGTERM, 15)
|
||||
|
||||
## Other tests.
|
||||
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
extends "res://addons/gut/test.gd"
|
||||
|
||||
|
||||
class MockPTY:
|
||||
extends "res://addons/godot_xterm/nodes/pty/pty_native.gd"
|
||||
|
||||
func write(data):
|
||||
emit_signal("data_received", data)
|
||||
|
||||
|
||||
class BaseTest:
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
var pty
|
||||
var mock_pty_native: MockPTY
|
||||
var mock_pty_native: PTY
|
||||
|
||||
func before_each():
|
||||
pty = add_child_autofree(PTY.new())
|
||||
mock_pty_native = autofree(MockPTY.new())
|
||||
pty._pty_native = mock_pty_native
|
||||
mock_pty_native = autofree(PTY.new())
|
||||
watch_signals(mock_pty_native)
|
||||
|
||||
|
||||
|
@ -70,33 +61,17 @@ class TestPTYInterfaceGodotXterm2_0_0:
|
|||
func test_has_signal_exited():
|
||||
assert_has_signal(pty, "exited")
|
||||
|
||||
# NOTE: This differs from the GodotXterm 2.x API which uses Signal rather than IPCSignal.
|
||||
# In Godot 4.x, enums are no longer dictionaries and thus need to be inspected individually.
|
||||
func test_has_enum_Signal():
|
||||
assert_true("IPCSignal" in pty, "Expected pty to have enum IPCSignal.")
|
||||
assert_typeof(pty.IPCSignal, typeof(Dictionary()))
|
||||
var signals = {
|
||||
SIGHUP = 1,
|
||||
SIGINT = 2,
|
||||
SIGQUIT = 3,
|
||||
SIGILL = 4,
|
||||
SIGTRAP = 5,
|
||||
SIGABRT = 6,
|
||||
SIGFPE = 8,
|
||||
SIGKILL = 9,
|
||||
SIGSEGV = 11,
|
||||
SIGPIPE = 13,
|
||||
SIGALRM = 14,
|
||||
SIGTERM = 15,
|
||||
}
|
||||
assert_gt(
|
||||
pty.IPCSignal.size(),
|
||||
signals.size() - 1,
|
||||
"Expected Signal enum to have at least %d members." % signals.size()
|
||||
)
|
||||
for signame in signals.keys():
|
||||
assert_has(pty.IPCSignal, signame, "Expected Signal enum to have member %s." % signame)
|
||||
assert_eq(
|
||||
pty.IPCSignal[signame],
|
||||
signals[signame],
|
||||
"Expected Signal enum member %s to have value %d." % [signame, signals[signame]]
|
||||
)
|
||||
assert_eq(pty.IPCSIGNAL_SIGHUP, 1, "Expected pty to have IPCSIGNAL_SIGHUP.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGINT, 2, "Expected pty to have IPCSIGNAL_SIGINT.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGQUIT, 3, "Expected pty to have IPCSIGNAL_SIGQUIT.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGILL, 4, "Expected pty to have IPCSIGNAL_SIGILL.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGTRAP, 5, "Expected pty to have IPCSIGNAL_SIGTRAP.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGABRT, 6, "Expected pty to have IPCSIGNAL_SIGABRT.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGFPE, 8, "Expected pty to have IPCSIGNAL_SIGFPE.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGKILL, 9, "Expected pty to have IPCSIGNAL_SIGKILL.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGSEGV, 11, "Expected pty to have IPCSIGNAL_SIGSEGV.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGPIPE, 13, "Expected pty to have IPCSIGNAL_SIGPIPE.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGALRM, 14, "Expected pty to have IPCSIGNAL_SIGALRM.")
|
||||
assert_eq(pty.IPCSIGNAL_SIGTERM, 15, "Expected pty to have IPCSIGNAL_SIGTERM.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue