Sha256: fd8ba7cf7bbfb321f56ca45be9f7a09cf366f41fc7419565784427b25974ff13

Contents?: true

Size: 963 Bytes

Versions: 21

Compression:

Stored size: 963 Bytes

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

require File.expand_path('../test_helper', __FILE__)


# --  Tests ----
class ExcludeThreadsTest < Test::Unit::TestCase
  def test_exclude_threads

    def thread1_proc
      sleep(0.5)
      sleep(2)
    end

    def thread2_proc
      sleep(0.5)
      sleep(2)
    end

    thread1 = Thread.new do
      thread1_proc
    end

    thread2 = Thread.new do
      thread2_proc
    end

    RubyProf::exclude_threads = [ thread2 ]

    RubyProf.start

    thread1.join
    thread2.join

    result = RubyProf.stop

    RubyProf::exclude_threads = nil

    assert_equal(2, result.threads.length)

    output = Array.new
    result.threads.each do |thread|
      thread.methods.each do | m |
        if m.full_name.index("ExcludeThreadsTest#thread") == 0
          output.push(m.full_name)
        end
      end
    end

    assert_equal(1, output.length)
    assert_equal("ExcludeThreadsTest#thread1_proc", output[0])
  end
end

Version data entries

21 entries across 19 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/ruby-prof-0.15.1/test/exclude_threads_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/ruby-prof-0.15.1/test/exclude_threads_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/ruby-prof-0.15.1/test/exclude_threads_test.rb
ruby-prof-0.15.2 test/exclude_threads_test.rb
ruby-prof-0.15.1 test/exclude_threads_test.rb
ruby-prof-0.15.0 test/exclude_threads_test.rb
ruby-prof-0.14.2 test/exclude_threads_test.rb
ruby-prof-0.14.1 test/exclude_threads_test.rb
ruby-prof-0.14.0 test/exclude_threads_test.rb
ruby-prof-0.13.1 test/exclude_threads_test.rb
ruby-prof-0.13.0 test/exclude_threads_test.rb
ruby-prof-0.12.2 test/exclude_threads_test.rb
ruby-prof-0.12.1-x86-mingw32 test/exclude_threads_test.rb
ruby-prof-0.12.1 test/exclude_threads_test.rb
ruby-prof-0.11.3 test/exclude_threads_test.rb
ruby-prof-0.11.2-x86-mingw32 test/exclude_threads_test.rb
ruby-prof-0.11.2 test/exclude_threads_test.rb
ruby-prof-0.11.0.rc3-x86-mingw32 test/exclude_threads_test.rb
ruby-prof-0.11.0.rc3 test/exclude_threads_test.rb
ruby-prof-0.11.0.rc2-x86-mingw32 test/exclude_threads_test.rb