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:
Leroy Hopson 2021-07-18 19:15:08 +07:00
parent 8bc3a13adb
commit b08d218a59
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
13 changed files with 154 additions and 40 deletions

View file

@ -1,9 +1,10 @@
name: build name: 'Build and Test'
on: [ push ] on: [ push ]
jobs: jobs:
build: build:
name: 'Build'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
@ -145,3 +146,92 @@ jobs:
addons/godot_xterm/native/bin/*.dylib addons/godot_xterm/native/bin/*.dylib
addons/godot_xterm/native/bin/*.dll addons/godot_xterm/native/bin/*.dll
test:
name: 'Test'
needs: build
env:
GODOT: Godot_v3.3.2-stable_${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ x11.64 ] #, x11.32, win64.exe, win32.exe, osx.universal ]
target: [ release, debug ]
include:
- platform: x11.64
os: ubuntu-latest
# For Windows platform we need to install mesa-dist-win.
# 32 bit X11 and MacOS also needs special attention.
# So disable all of them for now.
#- platform: x11.32
# os: ubuntu-latest
#- platform: win64.exe
# os: windows-latest
#- platform: win32.exe
# os: windows-latest
#- platform: osx.universal
# os: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache Godot
uses: actions/cache@v2
id: cache-godot
env:
cache-name: cache-godot
with:
path: godot_executable/
key: godot-cache-v1-${{ env.GODOT }}
#- name: Install 32 bit dependencies on 64 bit Ubuntu
# if: ${{ matrix.platform == 'x11.32' }}
# run: sudo apt-get install -y libxcursor-dev:i386
- name: Install Ubuntu dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y pulseaudio
- name: Download Godot
uses: suisei-cn/actions-download-file@v1
if: steps.cache-godot.outputs.cache-hit != 'true'
with:
url: https://downloads.tuxfamily.org/godotengine/3.3.2/${{ env.GODOT }}.zip
target: godot_executable/
- name: Extract Godot
shell: bash
if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
cd godot_executable
unzip ${{ env.GODOT }}.zip
- name: Symlink Godot
if: ${{ matrix.platform == 'osx.universal' }}
run: ln -s godot_executable/Godot.app/Contents/MacOS/Godot godot_executable/${{ env.GODOT }}
- name: Install binary build artifacts
uses: actions/download-artifact@v2
with:
name: libgodot-xterm-${{ matrix.target }}
path: addons/godot_xterm/native/bin
- name: Install plugins
uses: GabrielBB/xvfb-action@v1
with:
run: godot_executable/${{ env.GODOT }} --no-window -s plug.gd install
- name: Import files
uses: GabrielBB/xvfb-action@v1
with:
run: ./godot_executable/${{ env.GODOT }} --editor --quit
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: ./godot_executable/${{ env.GODOT }} --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.ci.json
- name: Run unix tests
if: ${{ matrix.platform != 'win64.exe' && matrix.platform != 'win32.exe' }}
uses: GabrielBB/xvfb-action@v1
with:
run: ./godot_executable/${{ env.GODOT }} --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.unix.json

6
.gitignore vendored
View file

@ -16,12 +16,16 @@ mono_crash.*
# IDE-specific ignores # IDE-specific ignores
.vscode .vscode
.vs
# Package-manager-specific ignores # Package-manager-specific ignores
.plugged .plugged
addons/*
!addons/gd-plug
!addons/godot_xterm
# Test-specific ignores # Test-specific ignores
addons/WAT .gutconfig.json
test/results.xml test/results.xml
test/test_metadata.json test/test_metadata.json

View file

@ -37,7 +37,7 @@ export (bool) var copy_on_selection
# Bell # Bell
# If enabled, bell_sound will play when the ASCII BELL "\u0007" character is printed. # If enabled, bell_sound will play when the ASCII BELL "\u0007" character is printed.
export var bell_enabled := true export var bell_enabled := true
export var bell_sound: AudioStream = preload("../../themes/audio/bell.wav") export var bell_sound: AudioStream
# Number of milliseconds that must pass before emitting a new bell sound. # Number of milliseconds that must pass before emitting a new bell sound.
# This important in cases where the bell character is being printed frequently # This important in cases where the bell character is being printed frequently
# such as `while true; do echo -e "\a"; done`, as adding additional AudioStreamPlayer # such as `while true; do echo -e "\a"; done`, as adding additional AudioStreamPlayer

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/godot_xterm/nodes/terminal/terminal.gd" type="Script" id=1] [ext_resource path="res://addons/godot_xterm/nodes/terminal/terminal.gd" type="Script" id=1]
[ext_resource path="res://examples/menu/menu.gd" type="Script" id=2] [ext_resource path="res://examples/menu/menu.gd" type="Script" id=2]
[ext_resource path="res://addons/godot_xterm/themes/audio/bell.wav" type="AudioStream" id=3]
[node name="Menu" type="Control"] [node name="Menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -20,5 +21,6 @@ script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
bell_sound = ExtResource( 3 )
[connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"] [connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"]

View file

@ -20,5 +20,3 @@ env = {
"COLORTERM": "truecolor", "COLORTERM": "truecolor",
"TERM": "xterm-256color" "TERM": "xterm-256color"
} }
[connection signal="bell" from="." to="." method="_on_Terminal_bell"]

View file

@ -2,4 +2,4 @@ extends "res://addons/gd-plug/plug.gd"
func _plugging(): func _plugging():
plug("AlexDarigan/WAT", {commit = "2136a1a440711bfdcc77ec8514d7590274bf6fb6"}) plug("bitwes/Gut", {commit = "5627110d9970c20949c1281a937e89d532f55341"})

View file

@ -56,7 +56,7 @@ window/vsync/use_vsync=false
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/WAT/plugin.cfg", "res://addons/godot_xterm/plugin.cfg" ) enabled=PoolStringArray( "godot_xterm", "gut" )
[rendering] [rendering]

11
test/.gutconfig.ci.json Normal file
View 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
View file

@ -0,0 +1,10 @@
{
"dirs": [
"res://test/platform/unix"
],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,
"log_level": 2,
"should_exit": true
}

View file

@ -0,0 +1,11 @@
{
"dirs": [
"res://platform/windows"
],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,
"log_level": 2,
"should_exit": true
}
}

View file

@ -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") const LibuvUtils = preload("res://addons/godot_xterm/nodes/pty/libuv_utils.gd")
@ -9,23 +9,23 @@ const TEST_VAL = "TEST123"
var env: Dictionary var env: Dictionary
func pre(): func before_each():
assert(OS.set_environment(EMPTY_VAR, "")) assert(OS.set_environment(EMPTY_VAR, ""))
assert(OS.set_environment(TEST_VAR, TEST_VAL)) assert(OS.set_environment(TEST_VAR, TEST_VAL))
env = LibuvUtils.get_os_environ() env = LibuvUtils.get_os_environ()
func test_has_empty_var(): func test_has_empty_var():
asserts.has(EMPTY_VAR, env) assert_has(env, EMPTY_VAR)
func test_empty_var_has_empty_val(): func test_empty_var_has_empty_val():
asserts.is_equal(env[EMPTY_VAR], "") assert_eq(env[EMPTY_VAR], "")
func test_has_test_var(): func test_has_test_var():
asserts.has(TEST_VAR, env) assert_has(env, TEST_VAR)
func test_test_var_has_correct_val(): func test_test_var_has_correct_val():
asserts.is_equal(env[TEST_VAR], TEST_VAL) assert_eq(env[TEST_VAR], TEST_VAL)

View file

@ -1,32 +1,28 @@
extends WAT.Test extends "res://addons/gut/test.gd"
var pty: GDXterm.PTYUnix var pty: GDXterm.PTYUnix
func pre(): func before_each():
pty = GDXterm.PTYUnix.new() pty = GDXterm.PTYUnix.new()
add_child(pty) add_child_autofree(pty)
func post():
pty.queue_free()
func test_fork_succeeds(): func test_fork_succeeds():
var err = pty.fork("sh") var err = pty.fork("sh")
asserts.is_equal(err, OK) assert_eq(err, OK)
func test_open_succeeds(): func test_open_succeeds():
var result = pty.open() var result = pty.open()
asserts.is_equal(result[0], OK) assert_eq(result[0], OK)
func test_open_creates_a_new_pty(): func test_open_creates_a_new_pty():
var num_pts = Helper._get_pts().size() var num_pts = Helper._get_pts().size()
pty.open() pty.open()
var new_num_pts = Helper._get_pts().size() 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(): func test_open_pty_has_correct_name():
@ -35,7 +31,7 @@ func test_open_pty_has_correct_name():
var new_pts = Helper._get_pts() var new_pts = Helper._get_pts()
for pt in original_pts: for pt in original_pts:
new_pts.erase(pt) 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(): func test_open_pty_has_correct_win_size():
@ -43,8 +39,8 @@ func test_open_pty_has_correct_win_size():
var rows = 9314 var rows = 9314
var result = pty.open(cols, rows) var result = pty.open(cols, rows)
var winsize = Helper._get_winsize(result[1].master) var winsize = Helper._get_winsize(result[1].master)
asserts.is_equal(winsize.cols, cols) assert_eq(winsize.cols, cols)
asserts.is_equal(winsize.rows, rows) assert_eq(winsize.rows, rows)
class Helper: class Helper:

View file

@ -1,20 +1,12 @@
extends WAT.Test extends "res://addons/gut/test.gd"
var term: GDXterm.Terminal var term: GDXterm.Terminal
func pre(): func before_each():
term = GDXterm.Terminal.new() term = GDXterm.Terminal.new()
term.rect_size = Vector2(400, 200) term.rect_size = Vector2(400, 200)
add_child(term) add_child_autofree(term)
func post():
term.free()
func after():
term.free()
func test_bell() -> void: func test_bell() -> void:
@ -23,5 +15,5 @@ func test_bell() -> void:
term.write("\a") term.write("\a")
term.write("\u0007") term.write("\u0007")
term.write("'Ask not for whom the \a tolls; it tolls for thee' - John Donne") term.write("'Ask not for whom the \a tolls; it tolls for thee' - John Donne")
yield(until_signal(term, "bell", 1), YIELD) yield(yield_to(term, "bell", 1), YIELD)
asserts.signal_was_emitted_x_times(term, "bell", 5) assert_signal_emit_count(term, "bell", 5)