~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to test/ruby/test_beginendblock.rb

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  def test_beginendblock
14
14
    ruby = EnvUtil.rubybin
15
15
    target = File.join(DIR, 'beginmainend.rb')
16
 
    result = IO.popen("#{q(ruby)} #{q(target)}"){|io|io.read}
 
16
    result = IO.popen([ruby, target]){|io|io.read}
17
17
    assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e4 e3 e2 e4-2 e4-1 e1-1 e4-1-1), result.split)
18
18
  end
19
19
 
38
38
STDERR.reopen(File.open(errout, "w"))
39
39
STDERR.sync = true
40
40
Dir.chdir(#{q(DIR)})
41
 
cmd = "\\"#{ruby}\\" \\"endblockwarn.rb\\""
42
 
system(cmd)
 
41
system("#{ruby}", "endblockwarn.rb")
43
42
EOF
44
43
    launcher.close
45
44
    launcherpath = launcher.path
46
45
    errout.close
47
46
    erroutpath = errout.path
48
 
    system("#{q(ruby)} #{q(launcherpath)} #{q(erroutpath)}")
 
47
    system(ruby, launcherpath, erroutpath)
49
48
    expected = <<EOW
50
49
endblockwarn.rb:2: warning: END in method; use at_exit
51
50
(eval):2: warning: END in method; use at_exit
57
56
  def test_raise_in_at_exit
58
57
    # [ruby-core:09675]
59
58
    ruby = EnvUtil.rubybin
60
 
    out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \
61
 
                   "at_exit{raise %[SomethingBad]};" \
62
 
                   "raise %[SomethingElse]'") {|f|
 
59
    out = IO.popen([ruby, '-e', 'STDERR.reopen(STDOUT)',
 
60
                     '-e', 'at_exit{raise %[SomethingBad]}',
 
61
                     '-e', 'raise %[SomethingElse]']) {|f|
63
62
      f.read
64
63
    }
65
64
    assert_match /SomethingBad/, out
68
67
 
69
68
  def test_should_propagate_exit_code
70
69
    ruby = EnvUtil.rubybin
71
 
    assert_equal false, system("#{q(ruby)} -e 'at_exit{exit 2}'")
 
70
    assert_equal false, system(ruby, '-e', 'at_exit{exit 2}')
72
71
    assert_equal 2, $?.exitstatus
73
72
    assert_nil $?.termsig
74
73
  end
75
74
 
76
75
  def test_should_propagate_signaled
77
76
    ruby = EnvUtil.rubybin
78
 
    out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \
79
 
                   "at_exit{Process.kill(:INT, $$)}'"){|f|
 
77
    out = IO.popen([ruby, '-e', 'STDERR.reopen(STDOUT)',
 
78
                     '-e', 'at_exit{Process.kill(:INT, $$)}']) {|f|
80
79
      f.read
81
80
    }
82
81
    assert_match /Interrupt$/, out