如何获得挂起Ruby进程的回溯?

时间:2018-08-24 13:10:20

标签: ruby interrupt backtrace

有一个复杂的测试套件,其中包含水豚,硒,魅力,并且都被滥用了:

  • 它会自行启动和退出Chrome,而不会将此工作留给Capybara
  • 在将钩子放置在错误的位置之前和之后,会导致诸如仅执行rspec --dry-run时填充远程数据库之类的影响
  • 魅力报告宝石几乎被遗弃了,我相信这里也没有没有错误的做法

现在,当我运行测试时,有时它们会挂起,因此我按^C,但它们并没有停止:

RSpec is shutting down and will print the summary report... Interrupt again to force quit.

无论等待多长时间,甚至手动关闭浏览器,它都不会停止。

当我再次按下^C时,它什么也不打印-没有回溯。
我怎么知道它挂在哪里?我如何随时获得追溯?

1 个答案:

答案 0 :(得分:0)

输出Ruby相关流程。

终止 Rspec 进程。

$ ps aux | grep ruby

jun               3517   0.0  0.0  4443772   1240 s000  S+   12:07AM   0:00.21 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/app/views
jun               3515   0.0  0.0  4434556   1360 s000  S+   12:07AM   0:00.22 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/db /Users/jun/workspace/sf/app/app/controllers /Users/jun/workspace/sf/app/app/forms /Users/jun/workspace/sf/app/app/helpers /Users/jun/workspace/sf/app/app/jobs /Users/jun/workspace/sf/app/app/mailer /Users/jun/workspace/sf/app/app/mailers /Users/jun/workspace/sf/app/app/models /Users/jun/workspace/sf/app/app/policies /Users/jun/workspace/sf/app/app/validators
jun               3514   0.0  0.0  4419196   1272 s000  S+   12:07AM   0:00.20 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/jdreamsr-app/spec/factories
jun               3513   0.0  0.0  4456060   1232 s000  S+   12:07AM   0:00.20 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/config/locales
jun              17370   0.0  0.0  4259000    248 s006  R+    3:04AM   0:00.00 grep ruby
$ kill -9 3517
$ kill -9 3515
...