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