From 21ef94956e5edfd7abf4750c46cd0d3b4eaa2a3b Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 22 Jun 2023 19:56:05 +0100 Subject: [PATCH 1/3] Run tests against TruffleRuby head Co-authored-by: Vinicius Stock --- .github/workflows/ci.yml | 4 ++-- test/test_helper.rb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 367e798afc..8cb31adbf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,10 @@ 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-head"] exclude: - os: windows-latest - ruby: "3.3" + ruby: "truffleruby-head" runs-on: ${{ matrix.os }} name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }} steps: 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) From 6dbbe97b929396c02103677bae7c717f365e64cf Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 27 Jun 2023 16:07:35 +0100 Subject: [PATCH 2/3] Wait for test process to die before closing IOs Co-authored-by: Kevin Menard --- test/integration_test.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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) From b97b566921161719499e81b47a4c9121f991e957 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 27 Jun 2023 16:32:26 +0100 Subject: [PATCH 3/3] Test against the latest TruffleRuby release too --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cb31adbf2..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", "truffleruby-head"] + ruby: ["3.0", "3.1", "3.2", "truffleruby", "truffleruby-head"] exclude: - os: windows-latest ruby: "truffleruby-head" + - os: windows-latest + ruby: "truffleruby" runs-on: ${{ matrix.os }} name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }} steps: