Sha256: fe1be90aec36e85cb46440ea0fcc19b004ccaf05921eab59e838f13875c33fc2

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# This executable checks if all automatic LSP requests run successfully on every Ruby file under the current directory

require "sorbet-runtime"

begin
  T::Configuration.default_checked_level = :never
  T::Configuration.call_validation_error_handler = ->(*) {}
  T::Configuration.inline_type_error_handler = ->(*) {}
  T::Configuration.sig_validation_error_handler = ->(*) {}
rescue
  nil
end

require_relative "../lib/ruby_lsp/internal"

RubyLsp::Addon.load_addons

T::Utils.run_all_sig_blocks

files = Dir.glob("#{Dir.pwd}/**/*.rb")

puts "Verifying that all automatic LSP requests execute successfully. This may take a while..."

errors = {}
store = RubyLsp::Store.new
message_queue = Thread::Queue.new
executor = RubyLsp::Executor.new(store, message_queue)

files.each_with_index do |file, index|
  uri = URI("file://#{file}")
  store.set(uri: uri, source: File.read(file), version: 1)

  # Executing any of the automatic requests will execute all of them, so here we just pick one
  result = executor.execute({
    method: "textDocument/documentSymbol",
    params: { textDocument: { uri: uri.to_s } },
  })

  error = result.error
  errors[file] = error if error
ensure
  store.delete(uri)
  print("\033[M\033[0KCompleted #{index + 1}/#{files.length}") unless ENV["CI"]
end

puts "\n"
message_queue.close

if errors.empty?
  puts "All automatic LSP requests executed successfully"
  exit
end

puts <<~ERRORS
  Errors while executing requests:

  #{errors.map { |file, error| "#{file}: #{error.message}" }.join("\n")}
ERRORS
exit!

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-lsp-0.12.0 exe/ruby-lsp-check
ruby-lsp-0.11.2 exe/ruby-lsp-check
ruby-lsp-0.11.1 exe/ruby-lsp-check
ruby-lsp-0.11.0 exe/ruby-lsp-check