Skip to content

Commit

Permalink
* test/test_pty.rb: Same as 229281; existence of PTY class do not
Browse files Browse the repository at this point in the history
	  guarantee a successful pty operation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shyouhei committed Sep 24, 2010
1 parent 9da7920 commit aa836e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Fri Sep 24 14:19:12 2010 URABE Shyouhei <shyouhei@ruby-lang.org>

* test/test_pty.rb: Same as 229281; existence of PTY class do not
guarantee a successful pty operation.

Thu Sep 23 23:09:08 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>

* vm_insnhelper.c (vm_get_cref0): cref is stacked only in normal
Expand Down
26 changes: 26 additions & 0 deletions test/test_pty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class TestPTY < Test::Unit::TestCase

def test_spawn_without_block
r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
rescue RuntimeError
skip $!
else
assert_equal("a\r\n", r.gets)
ensure
Process.wait pid if pid
Expand All @@ -23,6 +26,8 @@ def test_spawn_with_block
assert_equal("b\r\n", r.gets)
Process.wait(pid)
}
rescue RuntimeError
skip $!
end

def test_commandline
Expand All @@ -31,17 +36,24 @@ def test_commandline
assert_equal("foo\r\n", r.gets)
Process.wait(pid)
}
rescue RuntimeError
skip $!
end

def test_argv0
PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid|
assert_equal("bar\r\n", r.gets)
Process.wait(pid)
}
rescue RuntimeError
skip $!
end

def test_open_without_block
ret = PTY.open
rescue RuntimeError
skip $!
else
assert_kind_of(Array, ret)
assert_equal(2, ret.length)
assert_equal(IO, ret[0].class)
Expand Down Expand Up @@ -70,6 +82,9 @@ def test_open_with_block
assert(File.chardev?(slave.path))
x
}
rescue RuntimeError
skip $!
else
assert(r[0].closed?)
assert(r[1].closed?)
assert_equal(y, x)
Expand All @@ -82,6 +97,9 @@ def test_close_in_block
assert(slave.closed?)
assert(master.closed?)
}
rescue RuntimeError
skip $!
else
assert_nothing_raised {
PTY.open {|master, slave|
slave.close
Expand All @@ -97,6 +115,8 @@ def test_open
master.puts "bar"
assert_equal("bar", slave.gets.chomp)
}
rescue RuntimeError
skip $!
end

def test_stat_slave
Expand All @@ -105,13 +125,17 @@ def test_stat_slave
assert_equal(Process.uid, s.uid)
assert_equal(0600, s.mode & 0777)
}
rescue RuntimeError
skip $!
end

def test_close_master
PTY.open {|master, slave|
master.close
assert_raise(EOFError) { slave.readpartial(10) }
}
rescue RuntimeError
skip $!
end

def test_close_slave
Expand All @@ -123,6 +147,8 @@ def test_close_slave
Errno::EIO # GNU/Linux
) { master.readpartial(10) }
}
rescue RuntimeError
skip $!
end

def test_getpty_nonexistent
Expand Down

0 comments on commit aa836e5

Please sign in to comment.