mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test cleanup
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
20f635d6b2
commit
2a126b08a0
1 changed files with 26 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue