Class: RubyLLM::Toolbox::Tools::RunTests
- Includes:
- ToolchainHelpers
- Defined in:
- lib/ruby_llm/toolbox/tools/run_tests.rb
Overview
EXEC. Runs the project’s test suite (RSpec or Minitest) from fs_root and returns the output with a pass/fail headline. A failing suite is a normal result (the agent needs to see it), not a tool error.
Constant Summary collapse
- FRAMEWORKS =
%w[rspec minitest].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from ToolchainHelpers
#gemfile?, #jail_relative, #run_in_project, #toolchain_output
Methods inherited from Base
#call, exec_tool!, exec_tool?, #initialize, #name
Constructor Details
This class inherits a constructor from RubyLLM::Toolbox::Base
Instance Method Details
#execute(path: nil, framework: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_llm/toolbox/tools/run_tests.rb', line 29 def execute(path: nil, framework: nil) fw = (framework || detect_framework).to_s return error("could not detect a test framework (no spec/ or test/); set framework", code: :no_framework) if fw.empty? return error("unknown framework: #{fw} (use #{FRAMEWORKS.join(', ')})", code: :bad_framework) unless FRAMEWORKS.include?(fw) rel = jail_relative(path) out, err, status = fw == "rspec" ? run_rspec(rel) : run_minitest(rel) toolchain_output(out, err, status, pass_label: summarize(out, err, "TESTS PASSED"), fail_label: summarize(out, err, "TESTS FAILED")) rescue Safety::PathJail::Jailbreak => e error(e., code: :path_denied) rescue CommandMissing => e error("#{e.} is not available (is it in the bundle / installed?)", code: :unavailable) end |