2010-11-17 02:14:13 -05:00
|
|
|
require 'test/unit'
|
2011-06-29 09:19:59 -04:00
|
|
|
require 'tmpdir'
|
2010-11-17 02:14:13 -05:00
|
|
|
require_relative 'ruby/envutil'
|
|
|
|
|
|
|
|
class TestTracer < Test::Unit::TestCase
|
|
|
|
include EnvUtil
|
|
|
|
|
2011-06-29 09:19:59 -04:00
|
|
|
def test_tracer_with_option_r
|
|
|
|
assert_in_out_err(%w[-rtracer -e 1]) do |(*lines),|
|
2010-11-17 02:14:13 -05:00
|
|
|
case lines.size
|
|
|
|
when 2
|
2012-11-29 03:22:04 -05:00
|
|
|
assert_match(%r{rubygems/core_ext/kernel_require\.rb:\d+:Kernel:<:}, lines[0])
|
2010-11-17 02:14:13 -05:00
|
|
|
when 1
|
|
|
|
# do nothing
|
|
|
|
else
|
2012-11-29 03:22:04 -05:00
|
|
|
flunk "unexpected output from `ruby -rtracer -e 1`: #{lines.inspect}"
|
2010-11-17 02:14:13 -05:00
|
|
|
end
|
2011-01-13 21:02:12 -05:00
|
|
|
assert_equal "#0:-e:1::-: 1", lines.last
|
2010-11-17 02:14:13 -05:00
|
|
|
end
|
|
|
|
end
|
2011-06-29 09:19:59 -04:00
|
|
|
|
|
|
|
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
|
2010-11-17 02:14:13 -05:00
|
|
|
end
|