CHEF-3806 Fix for InSpec Parallel hangs for cetain CIS profile on Windows. (#71)

Sending EOF Marker at the end of of the whole suit run here instead of depending on the controls count

Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
Co-authored-by: Vasu1105 <vasundhara.jagdale@progress.com>
This commit is contained in:
Clinton Wolfe 2023-06-27 22:07:39 -04:00 committed by GitHub
parent 28031ae7ff
commit b9bc201ced
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
module InspecPlugins::Parallelism
class StreamingReporter < Inspec.plugin(2, :streaming_reporter)
# Registering these methods with RSpec::Core::Formatters class is mandatory
RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending
RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending, :close
def initialize(output)
@status_mapping = {}
@ -21,6 +21,11 @@ module InspecPlugins::Parallelism
set_example(notification, "skipped")
end
def close(notification)
# HACK: if we've reached the end of the execution, send a special marker, to ease EOF detection on Windows
puts "EOF_MARKER"
end
private
def set_example(notification, status)
@ -46,10 +51,6 @@ module InspecPlugins::Parallelism
display_name = control_id.to_s.lstrip.force_encoding(Encoding::UTF_8) unless title
puts "#{@control_counter}/#{stat}/#{controls_count}/#{display_name}"
# HACK: if we've reached the end of the execution, send a special marker, to ease EOF detection on Windows
if @control_counter == controls_count
puts "EOF_MARKER"
end
end
def set_status_mapping(control_id, status)