使用byebug
gem使我能够continue
直到下一个断点:
(byebug) help
break -- Sets breakpoints in the source code
catch -- Handles exception catchpoints
condition -- Sets conditions on breakpoints
continue -- Runs until program ends, hits a breakpoint or reaches a line
delete -- Deletes breakpoints
disable -- Disables breakpoints or displays
display -- Evaluates expressions every time the debugger stops
down -- Moves to a lower frame in the stack trace
edit -- Edits source files
enable -- Enables breakpoints or displays
finish -- Runs the program until frame returns
frame -- Moves to a frame in the call stack
help -- Helps you using byebug
history -- Shows byebug's history of commands
info -- Shows several informations about the program being debugged
interrupt -- Interrupts the program
irb -- Starts an IRB session
kill -- Sends a signal to the current process
list -- Lists lines of source code
method -- Shows methods of an object, class or module
next -- Runs one or more lines of code
pry -- Starts a Pry session
ps -- Evaluates an expression and prettyprints & sort the result
quit -- Exits byebug
restart -- Restarts the debugged program
save -- Saves current byebug session to a file
set -- Modifies byebug settings
show -- Shows byebug settings
source -- Restores a previously saved byebug session
step -- Steps into blocks or methods one or more times
thread -- Commands to manipulate threads
tracevar -- Enables tracing of a global variable
undisplay -- Stops displaying all or some expressions when program stops
untracevar -- Stops tracing a global variable
up -- Moves to a higher frame in the stack trace
var -- Shows variables and its values
where -- Displays the backtrace
我到处看了看,却找不到一个“没有断点继续”的方法。我能想到的唯一方法是删除或注释
byebug
语句,用q!
退出并重新启动测试。如何在ruby中不停地执行其他
byebug
语句? 最佳答案
代码中的方法调用不是“断点”(在帮助输出中考虑对断点的引用)。
根据帮助输出,可以使用byebug
命令禁用breakpoint
s。但这并不能解决您的问题,因为下一个disable
将再次暂停执行。
因为byebug
只是一个方法调用,所以可以将其设为条件调用:
byebug if SomeModule.byebug?
然后,在somemodule中,可以使用全局变量来打开/关闭它。你要么在所有对byebug的调用中都要这样做,要么你可以对byebug方法进行monkey-patch来执行相同的操作,
byebug
或类似的操作。“Make Byebug finish executing without exiting Pry”也是一个类似的答案。