junegunn commented on code in PR #8629:
URL: https://github.com/apache/hbase/pull/8629#discussion_r3959266301


##########
hbase-shell/src/test/ruby/shell/general_test_cluster.rb:
##########
@@ -226,4 +227,24 @@ def readable_after_eof?
     assert_match(/WARN: 'scan' is a reserved HBase command/, err_output)
     assert_match(/WARN: 'processlist' is a reserved HBase command/, err_output)
   end
+
+  def new_hirb(input_method)
+    IRB.setup(__FILE__) unless IRB.conf[:IRB_NAME]
+    IRB::HIRB.new(@shell.workspace, true, input_method)
+  end

Review Comment:
   The `unless IRB.conf[:IRB_NAME]` guard makes it idempotent, so only the 
first test that runs triggers setup. This mirrors the existing HBASE-28660 test 
above, which makes the same guarded call inline. Moving it to a suite hook 
would mean changing that test as well, which is beyond the scope of this fix.



##########
hbase-shell/src/test/ruby/shell/general_test_cluster.rb:
##########
@@ -226,4 +227,24 @@ def readable_after_eof?
     assert_match(/WARN: 'scan' is a reserved HBase command/, err_output)
     assert_match(/WARN: 'processlist' is a reserved HBase command/, err_output)
   end
+
+  def new_hirb(input_method)
+    IRB.setup(__FILE__) unless IRB.conf[:IRB_NAME]
+    IRB::HIRB.new(@shell.workspace, true, input_method)
+  end
+
+  define_test 'Shell::Shell should keep an interactive session alive on any 
error' do
+    hirb = new_hirb(MockInputMethod.new(["1 + '2'\n", "my_var = 5\n"]))
+    capture_stdout { hirb.eval_input }
+    assert_equal(5, hirb.context.workspace.binding.local_variable_get(:my_var))
+  end
+
+  define_test 'Shell::Shell should abort a script on error even when 
interactive' do
+    file = Tempfile.new(['hirb_test', '.rb'])
+    file.write("1 + '2'\n")
+    file.close
+    # interactive is true, as it is for `hbase shell script.rb` without -n
+    hirb = new_hirb(IRB::HBaseLoader.file_for_load(file.path))
+    assert_raise(TypeError) { capture_stdout { hirb.eval_input } }

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to