@@ -271,87 +271,92 @@ def print_it!
271271 $> = original_stdout
272272 end
273273
274- test "forked processes are named based on caller" do
275- skip ( "Fork is not supported on Windows" ) if Gem . win_platform?
276-
277- addon_path = File . expand_path ( "my_addon.rb" )
278- File . write ( addon_path , <<~RUBY )
279- class MyServerAddon < RubyLsp::Rails::ServerAddon
280- def name
281- "MyAddon"
282- end
283-
284- def execute(request, params)
285- parent_process_title = `ps -p \# {Process.pid} -o comm=`.lines.last.strip
286- file = "process_name.txt"
287- pid = fork do
288- # We can't directly send a message in these tests because we're using a StringIO as stdout instead of the
289- # actual pipe, which means that the child process doesn't have access to the same object
290- process_title = `ps -p \# {Process.pid} -o comm=`.lines.last.strip
291- File.write(file, process_title)
292- end
293-
294- Process.wait(pid)
295-
296- parent_process_title_changed = `ps -p \# {Process.pid} -o comm=`.lines.last.strip != parent_process_title
297- send_message({ process_name: File.read(file), changed_parent_title: parent_process_title_changed })
298- File.delete(file)
299- rescue => e
300- send_message({ error: e.full_message })
301- end
302- end
303- RUBY
304-
305- begin
306- @server . execute ( "server_addon/register" , server_addon_path : addon_path )
307- @server . execute ( "server_addon/delegate" , server_addon_name : "MyAddon" , request_name : "dsl" )
308- assert_equal ( response , { process_name : "ruby-lsp-rails: #{ addon_path } " , changed_parent_title : false } )
309- ensure
310- FileUtils . rm ( addon_path )
311- end
312- end
313-
314- test "forked processes with no block are named based on caller" do
315- skip ( "Fork is not supported on Windows" ) if Gem . win_platform?
316-
317- addon_path = File . expand_path ( "my_other_addon.rb" )
318- File . write ( addon_path , <<~RUBY )
319- class MyOtherServerAddon < RubyLsp::Rails::ServerAddon
320- def name
321- "MyOtherAddon"
322- end
323-
324- def execute(request, params)
325- parent_process_title = `ps -p \# {Process.pid} -o comm=`.lines.last.strip
326- file = "other_process_name.txt"
327- pid = fork
328-
329- if pid
330- Process.wait(pid)
331- parent_process_title_changed = `ps -p \# {Process.pid} -o comm=`.lines.last.strip != parent_process_title
332- send_message({ process_name: File.read(file), changed_parent_title: parent_process_title_changed })
333- File.delete(file)
334- else
335- process_title = `ps -p \# {Process.pid} -o comm=`.lines.last.strip
336- File.write(file, process_title)
337-
338- # Exit from the child process or else we're stuck in the infinite loop of the server
339- exit!
340- end
341- rescue => e
342- send_message({ error: e.full_message })
343- end
344- end
345- RUBY
346-
347- begin
348- @server . execute ( "server_addon/register" , server_addon_path : addon_path )
349- @server . execute ( "server_addon/delegate" , server_addon_name : "MyOtherAddon" , request_name : "dsl" )
350- assert_equal ( response , { process_name : "ruby-lsp-rails: #{ addon_path } " , changed_parent_title : false } )
351- ensure
352- FileUtils . rm ( addon_path )
353- end
354- end
274+ # test "forked processes are named based on caller" do
275+ # skip("Fork is not supported on Windows") if Gem.win_platform?
276+
277+ # addon_path = File.expand_path("my_addon.rb")
278+ # File.write(addon_path, <<~RUBY)
279+ # class MyServerAddon < RubyLsp::Rails::ServerAddon
280+ # def name
281+ # "MyAddon"
282+ # end
283+
284+ # def execute(request, params)
285+ # parent_process_title = process_title
286+ # file = "process_name.txt"
287+ # pid = fork do
288+ # # We can't directly send a message in these tests because we're using a StringIO as stdout instead of the
289+ # # actual pipe, which means that the child process doesn't have access to the same object
290+ # File.write(file, process_title)
291+ # end
292+
293+ # Process.wait(pid)
294+
295+ # parent_process_title_changed = process_title != parent_process_title
296+ # send_message({ process_name: File.read(file), changed_parent_title: parent_process_title_changed })
297+ # File.delete(file)
298+ # end
299+
300+ # private
301+
302+ # def process_title
303+ # `ps -p \#{Process.pid} -o comm=`.lines.last.strip
304+ # end
305+ # end
306+ # RUBY
307+
308+ # begin
309+ # @server.execute("server_addon/register", server_addon_path: addon_path)
310+ # @server.execute("server_addon/delegate", server_addon_name: "MyAddon", request_name: "dsl")
311+ # assert_equal(response, { process_name: "ruby-lsp-rails: #{addon_path}", changed_parent_title: false })
312+ # ensure
313+ # FileUtils.rm(addon_path)
314+ # end
315+ # end
316+
317+ # test "forked processes with no block are named based on caller" do
318+ # skip("Fork is not supported on Windows") if Gem.win_platform?
319+
320+ # addon_path = File.expand_path("my_other_addon.rb")
321+ # File.write(addon_path, <<~RUBY)
322+ # class MyOtherServerAddon < RubyLsp::Rails::ServerAddon
323+ # def name
324+ # "MyOtherAddon"
325+ # end
326+
327+ # def execute(request, params)
328+ # parent_process_title = process_title
329+ # file = "other_process_name.txt"
330+ # pid = fork
331+
332+ # if pid
333+ # Process.wait(pid)
334+ # parent_process_title_changed = process_title != parent_process_title
335+ # send_message({ process_name: File.read(file), changed_parent_title: parent_process_title_changed })
336+ # File.delete(file)
337+ # else
338+ # File.write(file, process_title)
339+ # # Exit from the child process or else we're stuck in the infinite loop of the server
340+ # exit!
341+ # end
342+ # end
343+
344+ # private
345+
346+ # def process_title
347+ # `ps -p \#{Process.pid} -o comm=`.lines.last.strip
348+ # end
349+ # end
350+ # RUBY
351+
352+ # begin
353+ # @server.execute("server_addon/register", server_addon_path: addon_path)
354+ # @server.execute("server_addon/delegate", server_addon_name: "MyOtherAddon", request_name: "dsl")
355+ # assert_equal(response, { process_name: "ruby-lsp-rails: #{addon_path}", changed_parent_title: false })
356+ # ensure
357+ # FileUtils.rm(addon_path)
358+ # end
359+ # end
355360
356361 private
357362
0 commit comments