Skip to content

Commit

Permalink
Try timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Oct 26, 2024
1 parent 9d5301e commit 35ad8ab
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ def test_launch_mode_with_no_gemfile_and_bundle_path
Bundler.with_unbundled_env do
system("bundle config --local path #{File.join("vendor", "bundle")}")
assert_path_exists(File.join(dir, ".bundle", "config"))
end

Bundler.with_unbundled_env do
launch(dir)
end
end
Expand All @@ -151,16 +148,7 @@ def test_launch_mode_with_no_gemfile_and_bundle_path
private

def launch(workspace_path)
load_path = $-I.map do |p|
"-I#{File.expand_path(p)}"
end.join(" ")

stdin, stdout, stderr, wait_thr = T.unsafe(Open3).popen3(
ENV.to_hash,
Gem.ruby,
load_path,
File.join(@root, "exe", "ruby-lsp-launcher"),
)
stdin, stdout, stderr, wait_thr = Open3.popen3(Gem.ruby, File.join(@root, "exe", "ruby-lsp-launcher"))
stdin.sync = true
stdin.binmode
stdout.sync = true
Expand All @@ -180,14 +168,17 @@ def launch(workspace_path)
send_message(stdin, { id: 2, method: "shutdown" })
send_message(stdin, { method: "exit" })

begin
Process.wait(wait_thr.pid)
rescue Errno::ECHILD
nil
# Wait until the process exits
wait_thr.join

unless T.unsafe(wait_thr.value).success?
require "timeout"

Timeout.timeout(5) do
flunk("Process failed\n#{stderr.read}")
end
end

wait_thr.join
refute_predicate(wait_thr, :alive?)
assert_path_exists(File.join(workspace_path, ".ruby-lsp", "bundle_gemfile"))
assert_path_exists(File.join(workspace_path, ".ruby-lsp", "Gemfile"))
assert_path_exists(File.join(workspace_path, ".ruby-lsp", "Gemfile.lock"))
Expand Down

0 comments on commit 35ad8ab

Please sign in to comment.