Implement action arguments logging
This commit is contained in:
parent
3cb195c9a0
commit
563bf9cccf
@ -16,8 +16,8 @@ Feature: CLI verbose option
|
||||
|
||||
Scenario: prints tasks name
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /^Task:.+`task_ok'/
|
||||
And the output must match /^Task:.+`task_ko'/
|
||||
Then the output must match /Task:.+`task_ok'/
|
||||
And the output must match /Task:.+`task_ko'/
|
||||
|
||||
Scenario: appends `applying' or `skipped' after tasks name
|
||||
When I successfully execute the recipe with option -v
|
||||
@ -28,6 +28,16 @@ Feature: CLI verbose option
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /^ action: echo/
|
||||
|
||||
Scenario: formats message with our simple logger
|
||||
Scenario: prints actions arguments
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /\ATask:/
|
||||
Then the output must match /echo \["some message"\]/
|
||||
|
||||
Scenario: summarizes printed actions arguments
|
||||
Given a recipe with:
|
||||
"""
|
||||
task :some_task do
|
||||
echo 'long message ' * 32
|
||||
end
|
||||
"""
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /action: .{,70}$/
|
||||
|
@ -1,6 +1,8 @@
|
||||
module Producer
|
||||
module Core
|
||||
class Action
|
||||
INSPECT_ARGUMENTS_SUM_LEN = 68.freeze
|
||||
|
||||
extend Forwardable
|
||||
def_delegators :@env, :input, :output, :error_output, :remote
|
||||
def_delegators :remote, :fs
|
||||
@ -17,7 +19,14 @@ module Producer
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
[name, inspect_arguments].join ' '
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def inspect_arguments
|
||||
@arguments.inspect[0, INSPECT_ARGUMENTS_SUM_LEN - name.length]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,7 @@ module Producer
|
||||
if task.condition_met?
|
||||
env.log "Task: `#{task}' applying..."
|
||||
task.actions.each do |e|
|
||||
env.log " action: #{e} applying"
|
||||
env.log " action: #{e}"
|
||||
e.apply unless env.dry_run?
|
||||
end
|
||||
else
|
||||
|
@ -54,8 +54,20 @@ module Producer::Core
|
||||
end
|
||||
|
||||
describe '#to_s' do
|
||||
it 'returns a word' do
|
||||
expect(action.to_s).to eq action.name
|
||||
it 'includes action name' do
|
||||
expect(action.to_s).to match /\A#{action.name}/
|
||||
end
|
||||
|
||||
it 'includes arguments inspection' do
|
||||
expect(action.to_s).to match /#{Regexp.quote(arguments.inspect)}\z/
|
||||
end
|
||||
|
||||
context 'when arguments inspection is very long' do
|
||||
let(:arguments) { [:some, :arguments] * 32 }
|
||||
|
||||
it 'summarizes arguments inspection' do
|
||||
expect(action.to_s.length).to be < 70
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user