summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-30 14:41:15 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-30 14:41:15 +0000
commit6a2b4ced6ad48ee7db0afdf564dcbb6cd3bfbd76 (patch)
tree69f8cad26225e868393315a079ec34a11a9cad0a
parent5727caf689097592fedf0a33420e1b8136c50c1a (diff)
merge revision(s) r46254,r48982,r48984: [Backport #10649]
test/io/console/test_io_console.rb: Close FDs. * ext/io/console/console.c (console_dev): id_console is not a constant name, use rb_const_remove() to get rid of NameError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/io/console/console.c2
-rw-r--r--test/io/console/test_io_console.rb35
-rw-r--r--version.h6
4 files changed, 37 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index ea9d12236a..f483fee5ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Mar 30 23:30:57 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/io/console/console.c (console_dev): id_console is not a
+ constant name, use rb_const_remove() to get rid of NameError.
+
Sun Mar 22 04:15:39 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/thread/thread.c (Init_thread): ConditionVariable and Queue
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index de5ca82558..85b6750c9f 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -689,7 +689,7 @@ console_dev(VALUE klass)
if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1)
return con;
}
- rb_mod_remove_const(klass, ID2SYM(id_console));
+ rb_const_remove(klass, id_console);
}
{
VALUE args[2];
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index a9de376a2b..baa44cfbef 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -217,18 +217,22 @@ class TestIO_Console < Test::Unit::TestCase
end
if IO.console
+ def test_close
+ IO.console.close
+ assert_kind_of(IO, IO.console)
+ assert_nothing_raised(IOError) {IO.console.fileno}
+ end
+
def test_sync
assert(IO.console.sync, "console should be unbuffered")
end
else
+ def test_close
+ assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0"))
+ end
+
def test_sync
- r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", "p IO.console.class")
- rescue RuntimeError
- skip $!
- else
- con = r.gets.chomp
- Process.wait(pid)
- assert_match("File", con)
+ assert_equal(["true"], run_pty("p IO.console.sync"))
end
end
@@ -243,6 +247,23 @@ class TestIO_Console < Test::Unit::TestCase
m.close if m
s.close if s
end
+
+ def run_pty(src)
+ r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src)
+ rescue RuntimeError
+ skip $!
+ else
+ result = r.readlines(&:chomp)
+ Process.wait(pid)
+ if block_given?
+ yield result
+ else
+ result
+ end
+ ensure
+ r.close if r
+ w.close if w
+ end
end if defined?(PTY) and defined?(IO::console)
class TestIO_Console < Test::Unit::TestCase
diff --git a/version.h b/version.h
index 4dc33a2aac..8ec02875c8 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.5"
-#define RUBY_RELEASE_DATE "2015-03-24"
-#define RUBY_PATCHLEVEL 321
+#define RUBY_RELEASE_DATE "2015-03-30"
+#define RUBY_PATCHLEVEL 322
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 24
+#define RUBY_RELEASE_DAY 30
#include "ruby/version.h"