Skip to content
Browse files

Various fixes to make testing easier:

* Support for 1.8.7 and 1.9.* load paths
* Add 1.9 encodings to each file
* Load the shared library from local lib directory instead of installed gem - makes testing much quicker/easier.
* Centralize path management for tests in test_helper.
* Adopt the lib/1.8 and lib/1.9 standard for fat gems for Windows.
  • Loading branch information...
1 parent 364ea80 commit 8b80da893647eac09f3ed97bd47eb4647e5ca3ec Charlie Savage committed Sep 5, 2011
View
18 lib/ruby-prof.rb
@@ -1,12 +1,13 @@
-# require the .so file...
-require File.dirname(__FILE__) + "/../ext/ruby_prof/ruby_prof"
+# Load the C-based binding.
+begin
+ RUBY_VERSION =~ /(\d+.\d+)/
+ require "#{$1}/ruby_prof"
+rescue LoadError
+ require "ruby_prof"
+end
+
module RubyProf
-
- if RUBY_VERSION < '1.8.7'
- require File.dirname(__FILE__) + '/ruby-prof/symbol_to_proc'
- end
-
def self.camelcase(phrase)
('_' + phrase).gsub(/_([a-z])/){|b| b[1..1].upcase}
end
@@ -28,7 +29,6 @@ def self.camelcase(phrase)
# we don't require unprof.rb, as well, purposefully
-
# Checks if the user specified the clock mode via
# the RUBY_PROF_MEASURE_MODE environment variable
def self.figure_measure_mode
@@ -64,4 +64,4 @@ def self.figure_measure_mode
end
end
-RubyProf::figure_measure_mode
+RubyProf::figure_measure_mode
View
4 test/aggregate_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
# Test data
# A B C
View
4 test/basic_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
class C1
def C1.hello
View
4 test/duplicate_names_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
class DuplicateNames < Test::Unit::TestCase
def test_names
View
4 test/enumerable_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
# -- Test for bug
# http://github.com/rdp/ruby-prof/issues#issue/12
View
5 test/exceptions_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
class ExceptionsTest < Test::Unit::TestCase
def test_profile
View
4 test/exclude_threads_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
# -- Tests ----
View
4 test/exec_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'os'
+require './test_helper'
# -- Test for bug when it loads with no frames
View
5 test/line_number_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
require 'prime'
class LineNumbers
View
5 test/measurement_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
class MeasurementTest < Test::Unit::TestCase
def setup
View
4 test/method_elimination_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
require 'tmpdir'
# Test data
View
5 test/module_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
# Need to use wall time for this test due to the sleep calls
RubyProf::measure_mode = RubyProf::WALL_TIME
View
4 test/multi_printer_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
require 'tmpdir'
# Test data
View
4 test/no_method_class_test.rb
@@ -1,5 +1,7 @@
#!/usr/bin/env ruby
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
# Make sure this works with no class or method
result = RubyProf.profile do
View
6 test/prime_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
-require 'prime'
+# encoding: UTF-8
+
+require './test_helper'
# -- Tests ----
class PrimeTest< Test::Unit::TestCase
View
8 test/printers_test.rb
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
-require File.dirname(__FILE__) + '/prime'
+# encoding: UTF-8
+
+require './test_helper'
+require './prime'
require 'stringio'
require 'fileutils'
-require 'rubygems'
# -- Tests ----
class PrintersTest < Test::Unit::TestCase
View
5 test/recursive_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
def simple(n)
sleep(1)
View
4 test/singleton_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
require 'timeout'
# -- Test for bug [#5657]
View
4 test/stack_printer_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
require 'tmpdir'
# Test data
View
4 test/stack_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
# Test data
# A
View
4 test/start_stop_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
class StartStopTest < Test::Unit::TestCase
def setup
View
14 test/test_helper.rb
@@ -0,0 +1,14 @@
+# encoding: UTF-8
+
+# To make testing/debugging easier, test within this source tree versus an installed gem
+
+dir = File.dirname(__FILE__)
+root = File.expand_path(File.join(dir, '..'))
+lib = File.expand_path(File.join(root, 'lib'))
+ext = File.expand_path(File.join(root, 'ext', 'ruby_prof'))
+
+$LOAD_PATH << lib
+$LOAD_PATH << ext
+
+require 'ruby-prof'
+require 'test/unit'
View
48 test/test_suite.rb
@@ -1,32 +1,26 @@
-begin
- require 'rubygems'
- require 'redgreen'
-rescue LoadError
-end
+require './test_helper'
-require 'test/unit'
-
-require 'aggregate_test'
-require 'basic_test'
-require 'duplicate_names_test'
-require 'exceptions_test'
-require 'line_number_test'
-require 'measurement_test'
-require 'module_test'
-require 'no_method_class_test'
-require 'prime_test'
-require 'printers_test'
-require 'recursive_test'
-require 'singleton_test'
-require 'stack_test'
-require 'start_stop_test'
-require 'thread_test'
-require 'unique_call_path_test'
-require 'stack_printer_test'
-require 'multi_printer_test'
-require 'method_elimination_test'
+require './aggregate_test'
+require './basic_test'
+require './duplicate_names_test'
+require './exceptions_test'
+require './line_number_test'
+require './measurement_test'
+require './module_test'
+require './no_method_class_test'
+require './prime_test'
+require './printers_test'
+require './recursive_test'
+require './singleton_test'
+require './stack_test'
+require './start_stop_test'
+require './thread_test'
+require './unique_call_path_test'
+require './stack_printer_test'
+require './multi_printer_test'
+require './method_elimination_test'
# Can't use this one here cause it breaks
# the rest of the unit tets (Ruby Prof gets
# started twice).
-#require 'profile_unit_test'
+#require './profile_unit_test'
View
5 test/thread_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
-require 'test/unit'
-require 'ruby-prof'
+# encoding: UTF-8
+
+require './test_helper'
require 'timeout'
# -- Tests ----
View
4 test/unique_call_path_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
-require 'test/unit'
-require 'ruby-prof'
+require './test_helper'
class UniqueCallPath
def method_a(i)

0 comments on commit 8b80da8

Please sign in to comment.
Something went wrong with that request. Please try again.