Project

General

Profile

« Previous | Next » 

Revision b29b1e98

Added by Swapnil Abnave about 6 years ago

Fixes #22244 - Skip whitelisted steps

View differences:

lib/foreman_maintain/cli/base.rb
'Automatically answer yes for all questions'
option(['-w', '--whitelist'], 'whitelist',
'Comma-separated list of labels of steps to be ignored') do |whitelist|
'Comma-separated list of labels of steps to be skipped') do |whitelist|
raise ArgumentError, 'value not specified' if whitelist.nil? || whitelist.empty?
whitelist.split(',').map(&:strip)
end
lib/foreman_maintain/executable.rb
# internal method called by executor
def __run__(execution)
setup_execution_state(execution)
run
unless skipped?
run
end
end
# method defined both on object and class to ensure we work always with object
lib/foreman_maintain/runner/execution.rb
def run
@reporter.before_execution_starts(self)
if skip?
@status = :already_run
return
end
@status = :running
@status = whitelisted? ? :skipped : :running
with_metadata_calculation do
capture_errors do
step.__run__(self)
end
end
# change the state only when not modified
@status = :success if @status == :running
ensure
test/lib/reporter_test.rb
MESSAGE
end
it 'ignores whitelisted warnings and failures of the last scenario' do
it 'skips whitelisted warnings and failures of the last scenario' do
run_scenario(warn_and_fail_scenario, :whitelisted => true)
reporter.after_scenario_finishes(warn_and_fail_scenario)
assert_equal <<-MESSAGE.strip_heredoc.strip, captured_out(false).strip
Check that ends up with warning: [WARNING]
this check is always causing warnings
Check that ends up with warning: [SKIPPED]
--------------------------------------------------------------------------------
Check that ends up with fail: [FAIL]
this check is always causing failure
Check that ends up with fail: [SKIPPED]
--------------------------------------------------------------------------------
Check that ends up with success: [OK]
Check that ends up with success: [SKIPPED]
--------------------------------------------------------------------------------
MESSAGE
end

Also available in: Unified diff