summaryrefslogtreecommitdiff
path: root/test/test_tracer.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 13:19:59 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 13:19:59 +0000
commite31caff00eaef9237e5825a7e9ccdae80a6fecf0 (patch)
tree9059707f62b6ecf80abf4344a86ee9b005b7a607 /test/test_tracer.rb
parentd073f1d53c9b72ab4fd1a02494999648c41b0868 (diff)
* lib/tracer.rb: Tracer.on only if required by -r command-line option.
and consider --disable-gems option. * test/test_tracer.rb: add tests for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_tracer.rb')
-rw-r--r--test/test_tracer.rb49
1 files changed, 46 insertions, 3 deletions
diff --git a/test/test_tracer.rb b/test/test_tracer.rb
index 8f542e6..a1e0a45 100644
--- a/test/test_tracer.rb
+++ b/test/test_tracer.rb
@@ -1,14 +1,15 @@
require 'test/unit'
+require 'tmpdir'
require_relative 'ruby/envutil'
class TestTracer < Test::Unit::TestCase
include EnvUtil
- def test_work_with_e
- assert_in_out_err(%w[--disable-gems -rtracer -e 1]) do |(*lines),|
+ def test_tracer_with_option_r
+ assert_in_out_err(%w[-rtracer -e 1]) do |(*lines),|
case lines.size
when 2
- assert_match %r[#0:<internal:lib/rubygems/custom_require>:\d+:Kernel:<: -], lines[0]
+ assert_match(%r{rubygems/custom_require\.rb:\d+:Kernel:<:}, lines[0])
when 1
# do nothing
else
@@ -17,4 +18,46 @@ class TestTracer < Test::Unit::TestCase
assert_equal "#0:-e:1::-: 1", lines.last
end
end
+
+ def test_tracer_with_option_r_without_gems
+ assert_in_out_err(%w[--disable-gems -rtracer -e 1]) do |(*lines),|
+ case lines.size
+ when 1
+ # do nothing
+ else
+ flunk "unexpected output from `ruby --disable-gems -rtracer -e 1`"
+ end
+ assert_equal "#0:-e:1::-: 1", lines.last
+ end
+ end
+
+ def test_tracer_with_require
+ Dir.mktmpdir("test_ruby_tracer") do |dir|
+ script = File.join(dir, "require_tracer.rb")
+ open(script, "w") do |f|
+ f.print <<-EOF
+require 'tracer'
+1
+ EOF
+ end
+ assert_in_out_err([script]) do |(*lines),|
+ assert_empty(lines)
+ end
+ end
+ end
+
+ def test_tracer_with_require_without_gems
+ Dir.mktmpdir("test_ruby_tracer") do |dir|
+ script = File.join(dir, "require_tracer.rb")
+ open(script, "w") do |f|
+ f.print <<-EOF
+require 'tracer'
+1
+ EOF
+ end
+ assert_in_out_err(["--disable-gems", script]) do |(*lines),|
+ assert_empty(lines)
+ end
+ end
+ end
end