mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-03 20:14:22 +02:00
Run tests in CI environment
Currently tests only run on X11.64 platform. But other platforms can be supported with a bit of effort. Remove default bell sound as it does not play nicely with CI environment that does not have sound card.
This commit is contained in:
parent
8bc3a13adb
commit
b08d218a59
13 changed files with 154 additions and 40 deletions
11
test/.gutconfig.ci.json
Normal file
11
test/.gutconfig.ci.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"dirs": [
|
||||
"res://test/unit",
|
||||
"res://test/integration"
|
||||
],
|
||||
"prefix": "",
|
||||
"suffix": ".test.gd",
|
||||
"include_subdirs": true,
|
||||
"log_level": 2,
|
||||
"should_exit": true
|
||||
}
|
10
test/.gutconfig.unix.json
Normal file
10
test/.gutconfig.unix.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"dirs": [
|
||||
"res://test/platform/unix"
|
||||
],
|
||||
"prefix": "",
|
||||
"suffix": ".test.gd",
|
||||
"include_subdirs": true,
|
||||
"log_level": 2,
|
||||
"should_exit": true
|
||||
}
|
11
test/.gutconfig.windows.json
Normal file
11
test/.gutconfig.windows.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"dirs": [
|
||||
"res://platform/windows"
|
||||
],
|
||||
"prefix": "",
|
||||
"suffix": ".test.gd",
|
||||
"include_subdirs": true,
|
||||
"log_level": 2,
|
||||
"should_exit": true
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
extends WAT.Test
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const LibuvUtils = preload("res://addons/godot_xterm/nodes/pty/libuv_utils.gd")
|
||||
|
||||
|
@ -9,23 +9,23 @@ const TEST_VAL = "TEST123"
|
|||
var env: Dictionary
|
||||
|
||||
|
||||
func pre():
|
||||
func before_each():
|
||||
assert(OS.set_environment(EMPTY_VAR, ""))
|
||||
assert(OS.set_environment(TEST_VAR, TEST_VAL))
|
||||
env = LibuvUtils.get_os_environ()
|
||||
|
||||
|
||||
func test_has_empty_var():
|
||||
asserts.has(EMPTY_VAR, env)
|
||||
assert_has(env, EMPTY_VAR)
|
||||
|
||||
|
||||
func test_empty_var_has_empty_val():
|
||||
asserts.is_equal(env[EMPTY_VAR], "")
|
||||
assert_eq(env[EMPTY_VAR], "")
|
||||
|
||||
|
||||
func test_has_test_var():
|
||||
asserts.has(TEST_VAR, env)
|
||||
assert_has(env, TEST_VAR)
|
||||
|
||||
|
||||
func test_test_var_has_correct_val():
|
||||
asserts.is_equal(env[TEST_VAR], TEST_VAL)
|
||||
assert_eq(env[TEST_VAR], TEST_VAL)
|
||||
|
|
|
@ -1,32 +1,28 @@
|
|||
extends WAT.Test
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
var pty: GDXterm.PTYUnix
|
||||
|
||||
|
||||
func pre():
|
||||
func before_each():
|
||||
pty = GDXterm.PTYUnix.new()
|
||||
add_child(pty)
|
||||
|
||||
|
||||
func post():
|
||||
pty.queue_free()
|
||||
add_child_autofree(pty)
|
||||
|
||||
|
||||
func test_fork_succeeds():
|
||||
var err = pty.fork("sh")
|
||||
asserts.is_equal(err, OK)
|
||||
assert_eq(err, OK)
|
||||
|
||||
|
||||
func test_open_succeeds():
|
||||
var result = pty.open()
|
||||
asserts.is_equal(result[0], OK)
|
||||
assert_eq(result[0], OK)
|
||||
|
||||
|
||||
func test_open_creates_a_new_pty():
|
||||
var num_pts = Helper._get_pts().size()
|
||||
pty.open()
|
||||
var new_num_pts = Helper._get_pts().size()
|
||||
asserts.is_equal(new_num_pts, num_pts + 1)
|
||||
assert_eq(new_num_pts, num_pts + 1)
|
||||
|
||||
|
||||
func test_open_pty_has_correct_name():
|
||||
|
@ -35,7 +31,7 @@ func test_open_pty_has_correct_name():
|
|||
var new_pts = Helper._get_pts()
|
||||
for pt in original_pts:
|
||||
new_pts.erase(pt)
|
||||
asserts.is_equal(result[1].pty, new_pts[0])
|
||||
assert_eq(result[1].pty, new_pts[0])
|
||||
|
||||
|
||||
func test_open_pty_has_correct_win_size():
|
||||
|
@ -43,8 +39,8 @@ func test_open_pty_has_correct_win_size():
|
|||
var rows = 9314
|
||||
var result = pty.open(cols, rows)
|
||||
var winsize = Helper._get_winsize(result[1].master)
|
||||
asserts.is_equal(winsize.cols, cols)
|
||||
asserts.is_equal(winsize.rows, rows)
|
||||
assert_eq(winsize.cols, cols)
|
||||
assert_eq(winsize.rows, rows)
|
||||
|
||||
|
||||
class Helper:
|
|
@ -1,20 +1,12 @@
|
|||
extends WAT.Test
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
var term: GDXterm.Terminal
|
||||
|
||||
|
||||
func pre():
|
||||
func before_each():
|
||||
term = GDXterm.Terminal.new()
|
||||
term.rect_size = Vector2(400, 200)
|
||||
add_child(term)
|
||||
|
||||
|
||||
func post():
|
||||
term.free()
|
||||
|
||||
|
||||
func after():
|
||||
term.free()
|
||||
add_child_autofree(term)
|
||||
|
||||
|
||||
func test_bell() -> void:
|
||||
|
@ -23,5 +15,5 @@ func test_bell() -> void:
|
|||
term.write("\a")
|
||||
term.write("\u0007")
|
||||
term.write("'Ask not for whom the \a tolls; it tolls for thee' - John Donne")
|
||||
yield(until_signal(term, "bell", 1), YIELD)
|
||||
asserts.signal_was_emitted_x_times(term, "bell", 5)
|
||||
yield(yield_to(term, "bell", 1), YIELD)
|
||||
assert_signal_emit_count(term, "bell", 5)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue