Sha256: 33f0d61fe4851f2c05874e70f7dd24871d47e3c211891b7b87a3e0425cd78b4d

Contents?: true

Size: 807 Bytes

Versions: 31

Compression:

Stored size: 807 Bytes

Contents

module InSubProcess
  if RUBY_PLATFORM == 'java'
    def in_sub_process
      pending "This spec requires forking to work properly, " +
              "and JRuby does not support forking"
    end
  else
    # Useful as a way to isolate a global change to a subprocess.
    def in_sub_process
      readme, writeme = IO.pipe

      pid = Process.fork do
        exception = nil
        begin
          yield
        rescue Exception => e
          exception = e
        end

        writeme.write Marshal.dump(exception)

        readme.close
        writeme.close
        exit! # prevent at_exit hooks from running (e.g. minitest)
      end

      writeme.close
      Process.waitpid(pid)

      exception = Marshal.load(readme.read)
      readme.close

      raise exception if exception
    end
  end
end

Version data entries

31 entries across 31 versions & 7 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-core-2.14.8/spec/support/in_sub_process.rb
rspec-core-2.99.2 spec/support/in_sub_process.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-core-2.14.7/spec/support/in_sub_process.rb
rspec-core-2.99.1 spec/support/in_sub_process.rb
rspec-core-2.99.0 spec/support/in_sub_process.rb
rspec-core-2.99.0.rc1 spec/support/in_sub_process.rb
rspec-core-2.14.8 spec/support/in_sub_process.rb
rspec-core-2.99.0.beta2 spec/support/in_sub_process.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-core-2.14.7/spec/support/in_sub_process.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/in_sub_process.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-core-2.14.7/spec/support/in_sub_process.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/in_sub_process.rb