Skip to content

Commit

Permalink
create cli boot via dry-rb system
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaumik-Ashraf committed Aug 19, 2024
1 parent 51f6cf2 commit 88c2412
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/inferno/apps/cli.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'thor'

require_relative 'cli/main'

module Inferno
Expand Down
5 changes: 3 additions & 2 deletions lib/inferno/apps/cli/execute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def self.suppress_output
retval
end

ENV['NO_DB'] = 'true'
# Inferno boot flow triggers migration and logger outputs it
suppress_output { require_relative '../../../inferno' }

Expand All @@ -53,7 +54,7 @@ def run(options)
print_start_message
verbose_puts 'options:', self.options

Inferno::Application.start(:suites)
Inferno::Application.start(:cli)

set_runnable!

Expand Down Expand Up @@ -112,7 +113,7 @@ def run(options)
end

def print_help_and_exit
puts `bundle exec inferno help execute`
puts `NO_DB=true bundle exec inferno help execute`
exit(3)
end

Expand Down
21 changes: 21 additions & 0 deletions lib/inferno/config/boot/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Inferno::Application.register_provider(:cli) do
prepare do
target_container.start :logging

require 'oj'
require 'blueprinter'

Blueprinter.configure do |config|
config.generator = Oj
end

target_container.start :suites

# This line is required to bypass the NO_DB env variable and load all repositories
# but the NO_DB env variable itself is required to bypass specific Inferno boot bugs
Dir.glob('../../../repositories/*.rb').each do |repository|
require_relative repository
puts "Require'd #{repository}"
end
end
end
4 changes: 3 additions & 1 deletion spec/inferno/apps/cli/execute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
RSpec.describe Inferno::CLI::Execute do # rubocop:disable RSpec/FilePath
let(:instance) { described_class.new }

# TODO: test print_help_and_exit, set_runnable, runnable_id_key, thor_hash_to_suite_options_array
# TODO: runnable_id_key, thor_hash_to_suite_options_array

# TODO this test catches a weird inferno glitch
describe '#print_help_and_exit' do
it 'outputs something and exits' do
expect do
Expand Down

0 comments on commit 88c2412

Please sign in to comment.