Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c69b2f7f4934
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 81472e5c0598
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Jun 19, 2016

  1. Squashed 'spec/mspec/' changes from 8ed21cb..52e059d

    52e059d Simply close the dup'd fd once we restored the original state
    3d38b3c Fix output_to_fd to let exceptions propagate
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 52e059d96d7264d2bd3919d36623f908d50861d4
    eregon committed Jun 19, 2016
    Copy the full SHA
    5ef25b0 View commit details
  2. Copy the full SHA
    9125888 View commit details
  3. Copy the full SHA
    4c84cdb View commit details
  4. [Truffle] New slow tags.

    eregon committed Jun 19, 2016
    Copy the full SHA
    81472e5 View commit details
46 changes: 22 additions & 24 deletions spec/mspec/lib/mspec/matchers/output_to_fd.rb
Original file line number Diff line number Diff line change
@@ -21,39 +21,37 @@ def initialize(expected, to)
end
end

def with_tmp
path = tmp("mspec_output_to_#{$$}_#{Time.now.to_i}")
File.open(path, 'w+') { |io|
yield(io)
}
ensure
File.delete path if path
end

def matches?(block)
old_to = @to.dup
out = File.open(tmp("mspec_output_to_#{$$}_#{Time.now.to_i}"), 'w+')

# Replacing with a file handle so that Readline etc. work
@to.reopen out

block.call

ensure
begin
@to.reopen old_to
with_tmp do |out|
# Replacing with a file handle so that Readline etc. work
@to.reopen out
begin
block.call
ensure
@to.reopen old_to
old_to.close
end

out.rewind
@actual = out.read

case @expected
when Regexp
return !(@actual =~ @expected).nil?
else
return @actual == @expected
end

# Clean up
ensure
out.close unless out.closed?
File.delete out.path
if !old_to.closed? and old_to.fileno != @to.fileno # reopen might create a new fd
old_to.close
when Regexp
!(@actual =~ @expected).nil?
else
@actual == @expected
end
end

return true
end

def failure_message()
9 changes: 9 additions & 0 deletions spec/mspec/spec/matchers/output_to_fd_spec.rb
Original file line number Diff line number Diff line change
@@ -12,6 +12,15 @@
output_to_fd("Hi\n", STDERR).matches?(lambda { $stderr.puts("Hello\n") }).should == false
end

it "propagate the exception if one is thrown while matching" do
exc = RuntimeError.new("propagates")
lambda {
output_to_fd("Hi\n", STDERR).matches?(lambda {
raise exc
}).should == false
}.should raise_error(exc)
end

it "defaults to matching against STDOUT" do
output_to_fd("Hi\n").matches?(lambda { $stdout.print "Hi\n" }).should == true
end
22 changes: 22 additions & 0 deletions spec/truffle/tags/core/kernel/spawn_tags.txt
Original file line number Diff line number Diff line change
@@ -147,3 +147,25 @@ fails:Kernel.spawn when passed close_others: true does not close STDERR
fails:Kernel.spawn when passed close_others: false does not close STDIN
fails:Kernel.spawn when passed close_others: false does not close STDOUT
fails:Kernel.spawn when passed close_others: false does not close STDERR
slow:Kernel#spawn redirects STDOUT to the given file if out: String
slow:Kernel#spawn redirects STDOUT to the given file if out: [String name, String mode]
slow:Kernel#spawn redirects STDERR to the given file if err: String
slow:Kernel#spawn does NOT redirect both STDERR and STDOUT at the time to the given name
slow:Kernel.spawn redirects STDOUT to the given file if out: String
slow:Kernel.spawn redirects STDOUT to the given file if out: [String name, String mode]
slow:Kernel.spawn redirects STDERR to the given file if err: String
slow:Kernel.spawn does NOT redirect both STDERR and STDOUT at the time to the given name
slow:Kernel#spawn redirects STDOUT to the given file descriptior if out: Fixnum
slow:Kernel#spawn redirects STDOUT to the given file if out: IO
slow:Kernel#spawn redirects STDERR to the given file descriptior if err: Fixnum
slow:Kernel#spawn redirects STDERR to the given file descriptor if err: IO
slow:Kernel#spawn redirects STDERR to child STDOUT if :err => [:child, :out]
slow:Kernel#spawn redirects both STDERR and STDOUT to the given file descriptior
slow:Kernel#spawn redirects both STDERR and STDOUT to the given IO
slow:Kernel.spawn redirects STDOUT to the given file descriptior if out: Fixnum
slow:Kernel.spawn redirects STDOUT to the given file if out: IO
slow:Kernel.spawn redirects STDERR to the given file descriptior if err: Fixnum
slow:Kernel.spawn redirects STDERR to the given file descriptor if err: IO
slow:Kernel.spawn redirects STDERR to child STDOUT if :err => [:child, :out]
slow:Kernel.spawn redirects both STDERR and STDOUT to the given file descriptior
slow:Kernel.spawn redirects both STDERR and STDOUT to the given IO
11 changes: 11 additions & 0 deletions spec/truffle/tags/core/process/spawn_tags.txt
Original file line number Diff line number Diff line change
@@ -72,3 +72,14 @@ fails:Process.spawn when passed close_others: true does not close STDERR
fails:Process.spawn when passed close_others: false does not close STDIN
fails:Process.spawn when passed close_others: false does not close STDOUT
fails:Process.spawn when passed close_others: false does not close STDERR
slow:Process.spawn redirects STDOUT to the given file descriptior if out: Fixnum
slow:Process.spawn redirects STDOUT to the given file if out: IO
slow:Process.spawn redirects STDOUT to the given file if out: String
slow:Process.spawn redirects STDOUT to the given file if out: [String name, String mode]
slow:Process.spawn redirects STDERR to the given file descriptior if err: Fixnum
slow:Process.spawn redirects STDERR to the given file descriptor if err: IO
slow:Process.spawn redirects STDERR to the given file if err: String
slow:Process.spawn redirects STDERR to child STDOUT if :err => [:child, :out]
slow:Process.spawn redirects both STDERR and STDOUT to the given file descriptior
slow:Process.spawn redirects both STDERR and STDOUT to the given IO
slow:Process.spawn does NOT redirect both STDERR and STDOUT at the time to the given name
12 changes: 7 additions & 5 deletions spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -146,12 +146,14 @@ if respond_to?(:ruby_exe)
end

class ::Object
alias old_ruby_exe ruby_exe
def ruby_exe(*args, &block)
if (MSpecScript.get(:xtags) || []).include? 'slow'
raise SlowSpecException, "Was tagged as slow as it uses ruby_exe(). Rerun specs."
%w[ruby_exe ruby_cmd].each do |meth|
alias_method "old_#{meth}", meth
define_method(meth) do |*args, &block|
if (MSpecScript.get(:xtags) || []).include? 'slow'
raise SlowSpecException, "Was tagged as slow as it uses #{meth}(). Rerun specs."
end
old_ruby_exe(*args, &block)
end
old_ruby_exe(*args, &block)
end
end