Sha256: 1179ac7551f9dea8fa110bd4496d6747f31deac7e30b14723aa2449397d65d92

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'bundler/setup'

require_relative './coverage' if ENV['COVERAGE']

require 'polyphony'

require 'fileutils'
require_relative './eg'

require 'minitest/autorun'
require 'minitest/reporters'

::Exception.__disable_sanitized_backtrace__ = true

Minitest::Reporters.use! [
  Minitest::Reporters::SpecReporter.new
]

class ::Fiber
  attr_writer :auto_watcher
end

class MiniTest::Test
  def setup
    # puts "* setup #{self.name}"
    if Fiber.current.children.size > 0
      puts "Children left: #{Fiber.current.children.inspect}"
      exit!
    end
    Fiber.current.setup_main_fiber
    Fiber.current.instance_variable_set(:@auto_watcher, nil)
    Thread.current.agent = Polyphony::Agent.new
    sleep 0 # apparently this helps with timer accuracy
  end

  def teardown
    # puts "* teardown #{self.name.inspect} Fiber.current: #{Fiber.current.inspect}"
    Fiber.current.terminate_all_children
    Fiber.current.await_all_children
    Fiber.current.auto_watcher = nil
  rescue => e
    puts e
    puts e.backtrace.join("\n")
    exit!
  end
end

module Kernel
  def capture_exception
    yield
  rescue Exception => e
    e
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polyphony-0.44.0 test/helper.rb
polyphony-0.43.11 test/helper.rb
polyphony-0.43.10 test/helper.rb