diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 367e798afc..82a088d398 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - ruby: ["3.0", "3.1", "3.2"] + ruby: ["3.0", "3.1", "3.2", "truffleruby", "truffleruby-head"] exclude: - os: windows-latest - ruby: "3.3" + ruby: "truffleruby-head" + - os: windows-latest + ruby: "truffleruby" runs-on: ${{ matrix.os }} name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }} steps: diff --git a/test/integration_test.rb b/test/integration_test.rb index 146ad637f9..86a4189649 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -41,10 +41,22 @@ def teardown make_request("shutdown") send_request("exit") - # Make sure IOs are closed - @stdin.close - @stdout.close - @stderr.close + # Give the server some time to process the "shutdown" and "exit" messages before + # closing the streams. Otherwise, it's possible the server misses one or both of them + # depending on what it's currently processing. This is wrapped in a timeout in case + # the server fails to process the messages. + begin + Timeout.timeout(60) do + sleep(0.010) while @wait_thr.alive? + end + rescue Timeout::Error + raise "The LSP server failed to shut down cleanly." + ensure + # Make sure IOs are closed + @stdin.close + @stdout.close + @stderr.close + end # Make sure the exit status is zero assert_equal(0, @wait_thr.value) diff --git a/test/test_helper.rb b/test/test_helper.rb index 94fda1e01a..99b1491913 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,11 +10,13 @@ require "minitest/autorun" require "minitest/reporters" require "tempfile" -require "debug" require "mocha/minitest" -sorbet_paths = Gem.loaded_specs["sorbet-runtime"].full_require_paths.freeze -DEBUGGER__::CONFIG[:skip_path] = Array(DEBUGGER__::CONFIG[:skip_path]) + sorbet_paths +unless RUBY_ENGINE == "truffleruby" || RUBY_PLATFORM =~ /mingw|mswin/ + require "debug" + sorbet_paths = Gem.loaded_specs["sorbet-runtime"].full_require_paths.freeze + DEBUGGER__::CONFIG[:skip_path] = Array(DEBUGGER__::CONFIG[:skip_path]) + sorbet_paths +end minitest_reporter = if ENV["SPEC_REPORTER"] Minitest::Reporters::SpecReporter.new(color: true)