-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into FI-3376-evaluator-firststep
- Loading branch information
Showing
15 changed files
with
256 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require_relative 'serialize' | ||
|
||
module Inferno | ||
module CLI | ||
class Execute | ||
# @private | ||
class JSONOutputter | ||
include Serialize | ||
|
||
def print_start_message(_options); end | ||
|
||
def print_around_run(_options, &) | ||
yield | ||
end | ||
|
||
def print_results(_options, results) | ||
puts serialize(results) | ||
end | ||
|
||
def print_end_message(_options); end | ||
|
||
def print_error(_options, exception) | ||
puts exception.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require_relative 'console_outputter' | ||
|
||
module Inferno | ||
module CLI | ||
class Execute | ||
# @private | ||
class PlainOutputter < ConsoleOutputter | ||
def print_error(_options, exception) | ||
puts "Error: #{exception.full_message(highlight: false)}" | ||
end | ||
|
||
def color | ||
@color ||= Pastel.new(enabled: false) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Inferno | ||
module CLI | ||
class Execute | ||
# @private | ||
class QuietOutputter | ||
def print_start_message(_options); end | ||
|
||
def print_around_run(_options, &) | ||
yield | ||
end | ||
|
||
def print_results(_options, _results); end | ||
|
||
def print_end_message(_options); end | ||
|
||
def print_error(options, exception) | ||
puts "Error: #{exception.full_message}" if options[:verbose] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'active_support' | ||
require_relative '../../web/serializers/test_run' | ||
require_relative '../../web/serializers/result' | ||
|
||
module Inferno | ||
module CLI | ||
class Execute | ||
# @private | ||
module Serialize | ||
def serialize(entity) | ||
case entity.class.to_s | ||
when 'Array' | ||
JSON.pretty_generate(entity.map { |item| JSON.parse serialize(item) }) | ||
else | ||
Inferno::Web::Serializers.const_get(entity.class.to_s.demodulize).render(entity) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require_relative '../../../../lib/inferno/apps/cli/execute/json_outputter' | ||
require_relative 'outputter_spec' | ||
|
||
RSpec.describe Inferno::CLI::Execute::JSONOutputter do | ||
include_examples 'outputter_spec', described_class | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
RSpec.shared_examples 'outputter_spec' do |outputter_class| | ||
it 'responds to print_start_message' do | ||
expect(outputter_class.new).to respond_to(:print_start_message) | ||
end | ||
|
||
it 'responds to print_around_run' do | ||
expect(outputter_class.new).to respond_to(:print_around_run) | ||
end | ||
|
||
it 'method print_around_run yields' do | ||
expect do | ||
expect { |b| outputter_class.new.print_around_run({}, &b) }.to yield_control | ||
end.to output(/.?/).to_stdout_from_any_process # required to prevent output in rspec | ||
end | ||
|
||
it 'responds to print_results' do | ||
expect(outputter_class.new).to respond_to(:print_results) | ||
end | ||
|
||
it 'responds to print_end_message' do | ||
expect(outputter_class.new).to respond_to(:print_end_message) | ||
end | ||
|
||
it 'responds to print_error' do | ||
expect(outputter_class.new).to respond_to(:print_error) | ||
end | ||
|
||
it 'returns an object whose print_error does not raise exception nor exit' do | ||
expect do | ||
expect { outputter_class.new.print_error({}, StandardError.new('my error')) }.to_not raise_error | ||
end.to output(/.?/).to_stdout # required to prevent output in rspec | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require_relative '../../../../lib/inferno/apps/cli/execute/plain_outputter' | ||
require_relative 'outputter_spec' | ||
|
||
RSpec.describe Inferno::CLI::Execute::PlainOutputter do | ||
let(:instance) { described_class.new } | ||
let(:results) { create_list(:result, 2) } | ||
let(:options) { { outputter: 'plain', verbose: true } } | ||
|
||
include_examples 'outputter_spec', described_class | ||
|
||
it 'never outputs a color code' do | ||
expect do | ||
instance.print_start_message(options) | ||
instance.print_around_run(options) { ' ' } | ||
instance.print_results(options, results) | ||
instance.print_end_message(options) | ||
# instance.print_error(options, StandardError.new('Mock Error')) | ||
end.to_not output(/\033/).to_stdout | ||
end | ||
end |
Oops, something went wrong.