Module: Straycall::RSpec
- Defined in:
- lib/straycall/rspec.rb
Class Method Summary collapse
Class Method Details
.configure_hooks ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/straycall/rspec.rb', line 30 def configure_hooks ::RSpec.configure do |config| config.before do |example| Straycall::RSpec.ensure_supervisor! Target.reporter&.notify_example( file: example.[:file_path], line: example.[:line_number], description: example.full_description ) end config.after(:suite) do begin Straycall::RSpec.ensure_supervisor! raise Error, "syscall violations were detected; see the straycall report" if Target.violation? ensure Target.stop end end end end |
.ensure_supervisor! ⇒ Object
51 52 53 54 55 |
# File 'lib/straycall/rspec.rb', line 51 def ensure_supervisor! return unless Seccomp::Notify.supervisor_alive? == false raise Error, "straycall supervisor stopped; refusing to continue with an unmonitored suite" end |
.install ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/straycall/rspec.rb', line 10 def install if RUBY_PLATFORM.include?("linux") && RUBY_ENGINE == "ruby" require "seccomp/notify" require_relative "target" return configure_hooks if Seccomp::Notify.supervisor_alive? end unless Straycall.available? Straycall.warn_unavailable! return end require "seccomp/notify" require_relative "in_process" require_relative "target" supervisor_socket, target_socket = UNIXSocket.pair InProcess.install(Straycall.config, report_socket: supervisor_socket, inherited_report_socket: target_socket) Target.start(target_socket) configure_hooks end |