| 1 | require "tempfile" |
| 2 | require_relative "../helper" |
| 3 | |
| 4 | module TestIRB |
| 5 | class MultiIRBTest < IntegrationTestCase |
| 6 | def setup |
| 7 | super |
| 8 | |
| 9 | write_ruby <<~'RUBY' |
| 10 | binding.irb |
| 11 | RUBY |
| 12 | end |
| 13 | |
| 14 | def test_jobs_command_with_print_deprecated_warning |
| 15 | out = run_ruby_file do |
| 16 | type "jobs" |
| 17 | type "exit" |
| 18 | end |
| 19 | |
| 20 | assert_match(/Multi-irb commands are deprecated and will be removed in IRB 2\.0\.0\. Please use workspace commands instead\./, out) |
| 21 | assert_match(%r|If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653|, out) |
| 22 | assert_match(/#0->irb on main \(#<Thread:0x.+ run>: running\)/, out) |
| 23 | end |
| 24 | |
| 25 | def test_irb_jobs_and_kill_commands |
| 26 | out = run_ruby_file do |
| 27 | type "irb" |
| 28 | type "jobs" |
| 29 | type "kill 1" |
| 30 | type "exit" |
| 31 | end |
| 32 | |
| 33 | assert_match(/#0->irb on main \(#<Thread:0x.+ sleep_forever>: stop\)/, out) |
| 34 | assert_match(/#1->irb#1 on main \(#<Thread:0x.+ run>: running\)/, out) |
| 35 | end |
| 36 | |
| 37 | def test_irb_fg_jobs_and_kill_commands |
| 38 | out = run_ruby_file do |
| 39 | type "irb" |
| 40 | type "fg 0" |
| 41 | type "jobs" |
| 42 | type "kill 1" |
| 43 | type "exit" |
| 44 | end |
| 45 | |
| 46 | assert_match(/#0->irb on main \(#<Thread:0x.+ run>: running\)/, out) |
| 47 | assert_match(/#1->irb#1 on main \(#<Thread:0x.+ sleep_forever>: stop\)/, out) |
| 48 | end |
| 49 | end |
| 50 | end |