Port prof to use AbstractCommand
This commit is contained in:
parent
5364b6ef03
commit
2dceb65b42
@ -1,13 +1,14 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def prof_args
|
||||
module DevCmd
|
||||
class Prof < AbstractCommand
|
||||
sig { override.returns(CLI::Parser) }
|
||||
def raw_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Run Homebrew with a Ruby profiler. For example, `brew prof readall`.
|
||||
@ -19,9 +20,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def prof
|
||||
args = prof_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
Homebrew.install_bundler_gems!(groups: ["prof"], setup_path: false)
|
||||
|
||||
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
||||
@ -42,7 +42,7 @@ module Homebrew
|
||||
|
||||
Homebrew.setup_gem_environment!
|
||||
|
||||
if args.stackprof?
|
||||
if args[:stackprof?]
|
||||
with_env HOMEBREW_STACKPROF: "1" do
|
||||
system(*HOMEBREW_RUBY_EXEC_ARGS, brew_rb, *args.named)
|
||||
end
|
||||
@ -62,4 +62,6 @@ module Homebrew
|
||||
args = ARGV - ["--"]
|
||||
puts "Try `brew prof -- #{args.join(" ")}` instead."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew prof" do
|
||||
it_behaves_like "parseable arguments"
|
||||
require "dev-cmd/prof"
|
||||
|
||||
RSpec.describe Homebrew::DevCmd::Prof do
|
||||
describe "integration tests", :integration_test, :needs_network do
|
||||
after do
|
||||
FileUtils.rm_rf HOMEBREW_LIBRARY_PATH/"prof"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user