File: test_tracer.rb

package info (click to toggle)
jruby 1.7.26-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 84,572 kB
  • sloc: ruby: 669,910; java: 253,056; xml: 35,152; ansic: 9,187; yacc: 7,267; cpp: 5,244; sh: 1,036; makefile: 345; jsp: 48; tcl: 40
file content (63 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'test/unit'
require 'tmpdir'
require_relative 'ruby/envutil'

class TestTracer < Test::Unit::TestCase
  include EnvUtil

  def test_tracer_with_option_r
    assert_in_out_err(%w[-rtracer -e 1]) do |(*lines),|
      case lines.size
      when 2
        assert_match(%r{rubygems/custom_require\.rb:\d+:Kernel:<:}, lines[0])
      when 1
        # do nothing
      else
        flunk "unexpected output from `ruby -rtracer -e 1`"
      end
      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