Skip to content
Permalink
Browse files

Merge pull request #548 from modcloth/mbh/backtick-process-status

Kernel#` sets $?
  • Loading branch information
alex committed Mar 27, 2013
2 parents 1d2d23f + ac6f2b0 commit 12e3f072a684cc9a31cf01e211f3d0d3afd111c4
Showing with 20 additions and 1 deletion.
  1. +6 −1 lib-topaz/kernel.rb
  2. +6 −0 lib-topaz/process.rb
  3. +8 −0 tests/modules/test_kernel.py
@@ -45,7 +45,12 @@ def loop
def `(cmd)
cmd = cmd.to_str if cmd.respond_to?(:to_str)
raise TypeError.new("can't convert #{cmd.class} into String") unless cmd.is_a?(String)
IO.popen(cmd) { |r| r.read }
res = ''
IO.popen(cmd) do |r|
res << r.read
Process.waitpid(r.pid)
end
res
end

def to_enum(method = :each, *args)
@@ -18,6 +18,12 @@ def initialize(pid, exitstatus)
@exitstatus = exitstatus
end

def success?
@exitstatus == 0
end

alias exited? success?

def pid
@pid
end
@@ -265,6 +265,14 @@ def test_backtick(self, space):
w_res = space.execute("return `echo 10`")
assert self.unwrap(space, w_res) == "10\n"

def test_backtick_sets_process_status(self, space):
w_res = space.execute("""
$? = nil
`echo`
return $?.class.name
""")
assert self.unwrap(space, w_res) == "Process::Status"


class TestRequire(BaseTopazTest):
def test_simple(self, space, tmpdir):

0 comments on commit 12e3f07

Please sign in to comment.
You can’t perform that action at this time.