diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64449a1..3e6cd0a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,10 @@ -name: build +name: 'Build and Test' on: [ push ] jobs: build: + name: 'Build' runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -145,3 +146,92 @@ jobs: addons/godot_xterm/native/bin/*.dylib 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 + diff --git a/.gitignore b/.gitignore index 0cfea06..3366fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,12 +16,16 @@ mono_crash.* # IDE-specific ignores .vscode +.vs # Package-manager-specific ignores .plugged +addons/* +!addons/gd-plug +!addons/godot_xterm # Test-specific ignores -addons/WAT +.gutconfig.json test/results.xml test/test_metadata.json diff --git a/addons/godot_xterm/nodes/terminal/terminal.gd b/addons/godot_xterm/nodes/terminal/terminal.gd index d9fe285..318735b 100644 --- a/addons/godot_xterm/nodes/terminal/terminal.gd +++ b/addons/godot_xterm/nodes/terminal/terminal.gd @@ -37,7 +37,7 @@ export (bool) var copy_on_selection # Bell # If enabled, bell_sound will play when the ASCII BELL "\u0007" character is printed. 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. # 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 diff --git a/examples/menu/menu.tscn b/examples/menu/menu.tscn index 771deff..43990c6 100644 --- a/examples/menu/menu.tscn +++ b/examples/menu/menu.tscn @@ -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://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"] anchor_right = 1.0 @@ -20,5 +21,6 @@ script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } +bell_sound = ExtResource( 3 ) [connection signal="key_pressed" from="Terminal" to="." method="_on_Terminal_key_pressed"] diff --git a/examples/terminal/terminal.tscn b/examples/terminal/terminal.tscn index 622fc4a..7c42c62 100644 --- a/examples/terminal/terminal.tscn +++ b/examples/terminal/terminal.tscn @@ -20,5 +20,3 @@ env = { "COLORTERM": "truecolor", "TERM": "xterm-256color" } - -[connection signal="bell" from="." to="." method="_on_Terminal_bell"] diff --git a/plug.gd b/plug.gd index e85abf6..35c6aff 100644 --- a/plug.gd +++ b/plug.gd @@ -2,4 +2,4 @@ extends "res://addons/gd-plug/plug.gd" func _plugging(): - plug("AlexDarigan/WAT", {commit = "2136a1a440711bfdcc77ec8514d7590274bf6fb6"}) + plug("bitwes/Gut", {commit = "5627110d9970c20949c1281a937e89d532f55341"}) diff --git a/project.godot b/project.godot index 0a9757c..764b145 100644 --- a/project.godot +++ b/project.godot @@ -56,7 +56,7 @@ window/vsync/use_vsync=false [editor_plugins] -enabled=PoolStringArray( "res://addons/WAT/plugin.cfg", "res://addons/godot_xterm/plugin.cfg" ) +enabled=PoolStringArray( "godot_xterm", "gut" ) [rendering] diff --git a/test/.gutconfig.ci.json b/test/.gutconfig.ci.json new file mode 100644 index 0000000..9f03b82 --- /dev/null +++ b/test/.gutconfig.ci.json @@ -0,0 +1,11 @@ +{ + "dirs": [ + "res://test/unit", + "res://test/integration" + ], + "prefix": "", + "suffix": ".test.gd", + "include_subdirs": true, + "log_level": 2, + "should_exit": true +} diff --git a/test/.gutconfig.unix.json b/test/.gutconfig.unix.json new file mode 100644 index 0000000..33098a9 --- /dev/null +++ b/test/.gutconfig.unix.json @@ -0,0 +1,10 @@ +{ + "dirs": [ + "res://test/platform/unix" + ], + "prefix": "", + "suffix": ".test.gd", + "include_subdirs": true, + "log_level": 2, + "should_exit": true +} diff --git a/test/.gutconfig.windows.json b/test/.gutconfig.windows.json new file mode 100644 index 0000000..a2017a9 --- /dev/null +++ b/test/.gutconfig.windows.json @@ -0,0 +1,11 @@ +{ + "dirs": [ + "res://platform/windows" + ], + "prefix": "", + "suffix": ".test.gd", + "include_subdirs": true, + "log_level": 2, + "should_exit": true +} +} diff --git a/test/integration/uv_utils.test.gd b/test/integration/uv_utils.test.gd index 221f9d4..d188109 100644 --- a/test/integration/uv_utils.test.gd +++ b/test/integration/uv_utils.test.gd @@ -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) diff --git a/test/integration/unix/unix.test.gd b/test/platform/unix/unix.test.gd similarity index 85% rename from test/integration/unix/unix.test.gd rename to test/platform/unix/unix.test.gd index 6e82486..18de93c 100644 --- a/test/integration/unix/unix.test.gd +++ b/test/platform/unix/unix.test.gd @@ -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: diff --git a/test/unit/terminal.test.gd b/test/unit/terminal.test.gd index 39e3c6b..3d22006 100644 --- a/test/unit/terminal.test.gd +++ b/test/unit/terminal.test.gd @@ -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)