Sha256: 78daa8072e8879d2fa28bbd2b5b3a5951961d9ab866693d602d72477cc9b0575

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require_relative 'helper'

class TraceTest < MiniTest::Test
  def test_tracing_enabled
    events = []
    Thread.backend.trace_proc = proc { |*e| events << e }
    snooze

    assert_equal [
      [:fiber_schedule, Fiber.current, nil, false],
      [:fiber_switchpoint, Fiber.current],
      [:fiber_run, Fiber.current, nil]
    ], events
  ensure
    Thread.backend.trace_proc = nil
  end

  def test_2_fiber_trace
    events = []
    Thread.backend.trace_proc = proc { |*e| events << e }

    f = spin { sleep 0; :byebye }
    suspend
    sleep 0

    assert_equal [
      [:fiber_create, f],
      [:fiber_schedule, f, nil, false],
      [:fiber_switchpoint, Fiber.current],
      [:fiber_run, f, nil],
      [:fiber_switchpoint, f],
      [:fiber_event_poll_enter, f],
      [:fiber_schedule, f, nil, false],
      [:fiber_event_poll_leave, f],
      [:fiber_run, f, nil],
      [:fiber_terminate, f, :byebye],
      [:fiber_switchpoint, f],
      [:fiber_switchpoint, Fiber.current],
      [:fiber_event_poll_enter, Fiber.current],
      [:fiber_schedule, Fiber.current, nil, false],
      [:fiber_event_poll_leave, Fiber.current],
      [:fiber_run, Fiber.current, nil]
    ], events
  ensure
    Thread.backend.trace_proc = nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polyphony-0.74 test/test_trace.rb
polyphony-0.73.1 test/test_trace.rb
polyphony-0.73 test/test_trace.rb
polyphony-0.72 test/test_trace.rb