summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-22 01:06:37 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-22 01:06:37 +0000
commit2a126b08a055ceacb6f540bd74e6d727f9d07883 (patch)
tree28d0955fd13aa8a825fc8a8d8a716c211ac16e2a /test/ruby
parent20f635d6b23332a5f3f4f6b0ffa1e2cf6d6b4089 (diff)
test cleanup
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_rubyoptions.rb30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 65b6c01031..69a7273f58 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -2,9 +2,26 @@ require 'test/unit'
require 'tmpdir'
require 'tempfile'
+require 'pathname'
+
require_relative 'envutil'
class TestRubyOptions < Test::Unit::TestCase
+ def write_file(filename, content)
+ File.open(filename, "w") {|f|
+ f << content
+ }
+ end
+
+ def with_tmpchdir
+ Dir.mktmpdir {|d|
+ d = Pathname.new(d).realpath.to_s
+ Dir.chdir(d) {
+ yield d
+ }
+ }
+ end
+
def test_source_file
assert_in_out_err([], "", [], [])
end
@@ -403,10 +420,15 @@ class TestRubyOptions < Test::Unit::TestCase
def test_set_program_name
skip if /linux|freebsd|netbsd|openbsd/ !~ RUBY_PLATFORM
- pid = spawn([EnvUtil.rubybin, %!-e "$0 = 'hello world'; sleep 100"!])
- ps = `ps -p #{pid} -o command`
- assert_match(/hello world/, ps)
- Process.kill :KILL, pid
+ with_tmpchdir do
+ write_file("test-script", "$0 = 'hello world'; sleep 60")
+
+ pid = spawn(EnvUtil.rubybin, "test-script")
+ sleep 0.1
+ ps = `ps -p #{pid} -o command`
+ assert_match(/hello world/, ps)
+ Process.kill :KILL, pid
+ end
end
def test_segv_test